I've appended a list item to my gallery of thumbnail images. The thumbnail shows up on the page and everything looks good. Now I want to click on the thumbnail image and show its image in a modal. But my click event doesn't get called because, when looking at the source, the html doesn't exist. I also need to sort the items and perform certain functions when the sorting is done a certain way. Do I need to refresh or something? It works fine for the other items that already exist in the gallery.  Here is the javascript that appends a list item to the DOM.    var base64 = arrayBufferToBase64(responseText.ImageThumbnail); var thumbSrc = "data:image/gif;base64," + base64; var base64Modal = arrayBufferToBase64(responseText.Image); var imgSrcModal = "data:image/gif;base64," + base64Modal; var imageId = "pop" + responseText.YogaSpaceImageId; var imagesourceId = "imagesource" + responseText.YogaSpaceImageId;   var listItem =   "&lt;li class=\"col-sm-6 col-md-4\"&gt;" +   "&lt;div class=\"thumbnail\"&gt;" +   "&lt;a class=\"close\" href=\"#\"&gt;×&lt;/a&gt;" +   "&lt;a class=\"image\" id=\"" + imageId + "\" href=\"\" data-toggle=\"modal\" data-target=\"#myModal\"&gt;" +   "&lt;img id=\"" + imagesourceId + "\" src=\"" + thumbSrc + "\" data-imagesrc=\"" + imgSrcModal + "\" alt=\"image not found\" width=\"203\" height=\"136\" /&gt;" +   "&lt;/a&gt;" +   "&lt;div class=\"caption\"&gt;" +   "&lt;h3&gt;Thumbnail label&lt;/h3&gt;" +   "&lt;p&gt;...&lt;/p&gt;" +   "&lt;p&gt;&lt;a href=\"#\" class=\"btn btn-primary\" role=\"button\"&gt;Button&lt;/a&gt; &lt;a href=\"#\" class=\"btn btn-default\" role=\"button\"&gt;Button&lt;/a&gt;&lt;/p&gt;" +   "&lt;/div&gt;" +   "&lt;/div&gt;" +   "&lt;/li&gt;";  var $li = $(listItem); $('ul#sortable').append($li);     This never gets called because its not in the source when I view it.    $('a.image').on("click", function () {     var imagesource = $(this).find('img:first').attr('id');     $('#modalPreview').attr('src', $('#' + imagesource).data('imagesrc'));     $('#imageModal').modal('show');  });
112
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.  This happens on page ready and works just fine.  The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound.  I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option.
99465
So i made a blog and I would like to put all the images in a post in a gallery/slider. I'm using the Enfold Child Theme so I looked up the gallery shortcode and made this function in the single.php(Single Post) where I get the image ids from a post and then I put them in the shortcode. The problem is, it doesn't show any images.. I Tried using the shortcode in a single post where I hardcoded the ids in the shortcode, and that worked perfectly. Anybody know what I'm doing wrong here or has a better solution? Thanks Single.php:  &lt;?php if (!function_exists('get_associated_media')) {      function get_associated_media($post_id) {         $attachmentIds = array();         $media = get_children(array(             'post_type' =&gt; 'attachment',             'post_parent' =&gt; $post_id,             'post_status' =&gt; 'inherit',             'post_mime_type' =&gt; array('image/jpeg', 'image/gif', 'image/png'),             'numberposts' =&gt; -1         ));          foreach ($media as $file) {             $attachmentIds[] = $file-&gt;ID;         }         $attachmentIds[] = get_post_thumbnail_id($post_id);         echo do_shortcode('[av_gallery ids=&quot;' . implode(&quot;,&quot;, $attachmentIds) . '&quot; type=&quot;slideshow&quot; style=&quot;big_thumb&quot; preview_size=&quot;portfolio&quot; crop_big_preview_thumbnail=&quot;avia-gallery-big-crop-thumb&quot; thumb_size=&quot;portfolio&quot; columns=&quot;5&quot; imagelink=&quot;lightbox&quot; lazyload=&quot;avia_lazyload&quot; av_uid=&quot;av-jgesnq4m&quot; custom_class=&quot;av-gallery-style-&quot;]');         return array_unique($attachmentIds);     } }  ?&gt;
24520
I need to display a bunch of images on a web page using AJAX. All of them have different dimensions, so I want to adjust their size before displaying them. Is there any way to do this in JavaScript?  Using PHP's getimagesize() for each image causes an unnecessary performance hit since there will be many images.
45155
I am attempting to replace JS buttons with quick actions. These button simply call a web service method and alert the result and need no user interaction.  With quick action a modal always seems to appear and this is not desirable.   I am calling the Webservice method in the doInit function and  firing a toast event with the results and have no need for the modal popup.  Seems an oversight maybe? But is there a way to accomplish this without the modal to closely mimic the JS button functionality?  Ideally we could show the spinner without the modal   Right now I am simply calling   $A.get("e.force:closeQuickAction").fire();   at the end of the doInit but it is not the most ideal in way of a UI to do this IMHO as it flashes the modal on the screen briefly.
10439
I need to use a JavaScript patch in my Google Sites, but the problem is I don't understand how to place them and use it as Google Gadget.  &lt;!DOCTYPE &lt;strong class="highlight"&gt;html&lt;/strong&gt; PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;&lt;strong class="highlight"&gt;html&lt;/strong&gt; xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script language="javascript" type="text/javascript"&gt; var timerid = 0; var &lt;strong class="highlight"&gt;images&lt;/strong&gt; = new Array(  "image1.jpg",             "image2.jpg",             "image3.jpg"); var countimages = 0; function startTime() {     if(timerid)     {         timerid = 0;     }     var tDate = new Date();      if(countimages == &lt;strong class="highlight"&gt;images&lt;/strong&gt;.length)     {         countimages = 0;     }     if(tDate.getSeconds() % 5 == 0)     {         document.getElementById("img1").src = &lt;strong class="highlight"&gt;images&lt;/strong&gt;[countimages];     }     countimages++;      timerid = setTimeout("startTime()", 1000); } &lt;/script&gt; &lt;/head&gt;  &lt;body onload="startTime();"&gt; &lt;img id="img1" src="image3.jpg" /&gt; &lt;/body&gt; &lt;/html&gt;   I'm hoping for specific instructions using the JavaScript code I provided since I've found general Google Sites embedding instructions unfathomable. However with specific instructions I will be able to figure out how to use scripts in Google Sites in the future as well.
15530
By adding use-ajax to a link we can open a modal using the Drupal ajax library as per the . E.g. &lt;a class=&quot;use-ajax&quot;      data-dialog-options=&quot;{&amp;quot;width&amp;quot;:400}&quot;      data-dialog-type=&quot;modal&quot;      href=&quot;/node/1&quot;&gt;     First article displayed in modal dialog. &lt;/a&gt;  This will use the ajax library to fetch node/1 and then display it in a modal. There is also a  which allows opening modals using JavaScript. E.g. var myDialog  = Drupal.dialog(ADOMElement, settings); myDialog.show();  The problem with this API is you need to pass in a existing DOM element. My question is can I trigger opening a modal with JavaScript and utalise the internal Drupal ajax library to actually fetch the content? E.g Can I do something like this? var myDialog  = Drupal.dialog('/node/1', {useAjax: true}); myDialog.show();  I could just create an html link as per my first code block, hide it with css, and then trigger a click on it with JS but this seems a bit hacky - there must be a way to trigger this action using pure JS.
51688
Can I add or change HTML when in 'Inspect Element'. I have a 'Home' link button that I want amend the link. I've used the right click option but my changes are not saved?
2497
I was reviewing in the close votes  when I clicked the "more" link for the specific close reason. I saw the following:    As you can see, the markup is not rendering. There's also a call to .AsHtml() in there which is obviously not markup.  Browser is chrome 31.0.1650.63
14827
I'm working on a 'sample request' implementation for a commerce site using , , sessions and a little custom code.  I'd like to add an icon or a symbol to let people know that an item they are viewing has been flagged.  I'm not sure exactly how to approach this, I can imagine perhaps adding a conditional field that displays an image or check box that is then changed by  or ajax, or perhaps something more complicated in JavaScript?  It could really be as simple as adding a checkbox that is checked or unchecked as the flag link is clicked or maybe even changing the css/html on click to be identified as marked.   Anyway, grateful for any advice here.
102242
I want to display popup with the data item, such as: name, coordinates, stationID, Attribute.  But my code has some problem that can't run.  &lt;html lang="en-US" xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head profile="http://gmpg.org/xfn/11"&gt;     &lt;link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css"           integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="           crossorigin="" /&gt;     &lt;script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"             integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="             crossorigin=""&gt;&lt;/script&gt;     &lt;script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"&gt;&lt;/script&gt;     &lt;script src="https://code.jquery.com/jquery-2.1.1.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt;     &lt;div id="map" style="height: 500px; border: 1px solid #AAA;"&gt;&lt;/div&gt;     &lt;script&gt;          var osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',             osmAttrib = '&amp;copy; &lt;a href="https://www.openstreetmap.org/copyright"&gt;OpenStreetMap&lt;/a&gt; contributors',             osm = L.tileLayer(osmUrl, { maxZoom: 20, attribution: osmAttrib });         var map = L.map('map').setView([24.151687694799833,120.64116954803465               ], 15).addLayer(osm);              //顯示地圖         L.control.scale().addTo(map);          $.getJSON("https://sta.ci.taiwan.gov.tw/STA_Rain/v1.0/Things?$expand=Locations&amp;$select=name,properties&amp;$count=true", function (data) {             var markerGroup = L.featureGroup();             data.value.forEach(function (itemData, itemInd) {                 var latLng = L.latLng(itemData.Locations[0].location.coordinates[1], itemData.Locations[0].location.coordinates[0]);                 var myMarker = L.marker(latLng).addTo(markerGroup);                 myMarker.bindPopup('ID: ' + itemData.properties.stationID + '&lt;br /&gt;Name: ' + itemData.properties.stationName);                    onEachFeature (itemData, layer) {                     layer.bindPopup("&lt;p&gt;&lt;/p&gt;"                         + itemData.name + "&lt;/p&gt;"                         + itemData.properties.Attribute +                         "&lt;/p&gt;Attribute: "                     );                 };             }).addTo(map);              markerGroup.addTo(map);             map.fitBounds(markerGroup.getBounds());                   });     &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;   This is my GeoJSON:  https://sta.ci.taiwan.gov.tw/STA_Rain/v1.0/Things?$expand=Locations&amp;$select=name,properties&amp;$count=true
61930
I'm reloading a web page that has the following code:  &lt;label for="showimage"&gt;Show Image&lt;/label&gt; &lt;input id="showimage" name="showimage" type="checkbox" value="1" /&gt;   Even though the HTML stays sent to the browser is the same for each reload of the page, the checkbox always takes on the checked value when a reload was performed.  In other words, if the user checks the checkbox and reloads, the checkbox is still checked.  Is there some caching going on here?    Edit: I tried Gordon Bell's solution below and find that this is still happening even after removing the value="1".  Anything else I might be missing?  &lt;label for="showimage"&gt;Show Image&lt;/label&gt;  &lt;input id="showimage" name="showimage" type="checkbox" /&gt;
72487
I have an HTML element with a large collection of unordered lists contained within it. I need to clone this element to place elsewhere on the page with different styles added (this is simple enough using jQuery).    $("#MainConfig").clone(false).appendTo($("#smallConfig"));   The problem, however, is that all the lists and their associated list items have IDs and clone duplicates them. Is there an easy way to replace all these duplicate IDs using jQuery before appending?
112030
I find it very inconvenient when I need to upload a file from a folder with A LOT of pictures and I need to inspect each file to find the image I'm looking for.   How do I make file dialog boxes view thumbnails like the way your file manager does?  Basically, from this:    To this:    I hear it's impossible. Is it true?
32194
How to add a custom action to the list ribbon?  The custom action should open a sitepage in modal popup.
38609
On our team site we have added a web part that is a "Picture Library Slideshow" web part. Currently clicking on the images that scroll in the slideshow directs the browser to just the image's URL. I would like to modify that to point to any other URL of my choice.   I have tried forcing a modification of the javascript that is generated by the slideshow webpart using my own script on the page. Looking at the source, the Picture Library uses a var that actually sets the links, it's called "linkArray":  var pictureArray = ['http://intranet/HomePicture/_w/image1.jpg','http://intranet/HomePicture/_w/image2.jpg']; var linkArray = ['http://intranet/HomePicture/image1.jpg','http://intranet/HomePicture/image2.jpg']; var titleArray = ['','']; var descriptionArray = ['','']; var heightArray = [268,268]; var widthArray = [383,383];   Using my own script I tried to clear out the array and insert my own links into it, but for some reason the links only update (i.e. my script's function runs) after the first image changes. Even if I manually change the first image's href tag, the script still thinks the "first" image is the second one that the slideshow scrolls to. Is there a way to force the function to overwrite the existing javascript immediately on page load?
79334
I have a medium-sized list (about a few dozen items, the container is very likely to have internal vertical scrolling). There is no sorting, so items are displayed in the order of their addition to the list. They are added through a series of controls located above the list with a "submit" button at the end. A colleague and I disagree as to where the new items should appear &ndash; at the bottom of the list, or at the top.
39810
In Prototype I can show a "loading..." image with this code:  var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars,  onLoading: showLoad, onComplete: showResponse} );  function showLoad () {     ... }   In jQuery, I can load a server page into an element with this:  $('#message').load('index.php?pg=ajaxFlashcard');   but how do I attach a loading spinner to this command as I did in Prototype?