Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I assume you have just included the slimbox JS file. It will not work as the DOM does not have the images when slimbox is loaded because they are added afterwards and slimbox only works for links which are ALREADY present when function is called.</p> <p>It's simple to achieve what you are saying by a little modification to slimbox.js. You'll find this at the bottom of slimbox.js:</p> <pre><code>// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED) if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) { jQuery(function($) { $("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) { return (this == el) || ((this.rel.length &gt; 8) &amp;&amp; (this.rel == el.rel)); }); }); } </code></pre> <p>Wrap it inside a function and just call it whenever you dynamically change DOM (after you append images). Change above code to this:</p> <pre><code>function loadsb(){ if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) { $("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) { return (this == el) || ((this.rel.length &gt; 8) &amp;&amp; (this.rel == el.rel)); }); } } </code></pre> <p>Call <code>loadsb()</code> after <code>appendTo('#FBalbum');</code></p> <p><strong>EDIT</strong>: Since you are having troubles let me make it even easier. </p> <p>Use this as your <code>slimbox.js</code>: <a href="http://pastebin.com/8iye0PEB" rel="nofollow">http://pastebin.com/8iye0PEB</a> . I've removed the function declaration from that file, will add it to the JS on main page.</p> <p>Now I see from your included JS, the Jquery object is not referenced by <code>$</code> , it is referenced by jQuery. so now your main page JS will be:</p> <pre><code>&lt;script&gt; //Function to load SlimBox. PS: I'm refrencing the jQuery object by "jQuery" and not $ sign because of your markup function loadsb(){ if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) { jQuery("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) { return (this == el) || ((this.rel.length &gt; 8) &amp;&amp; (this.rel == el.rel)); }); } } jQuery(document).ready(function() { var AlbumID = "163187497033669"; var graph = "https://graph.facebook.com/" + AlbumID + "/photos?callback=?"; jQuery.getJSON(graph, function(data) { var albumItem = []; for(var key in data){ for(var key2 in data[key]){ val2=data[key][key2]; if(typeof(val2.source)!="undefined"){ albumItem.push( '&lt;li&gt;&lt;a class="imageLink" rel="lightbox" href="' + val2.source + '" &gt;&lt;img src="' + val2.picture + '"/&gt;&lt;/a&gt;&lt;/li&gt;' ); }; }; }; jQuery('&lt;ul /&gt;', { 'class': 'album', html: albumItem.join('') }).appendTo('#FBalbum'); //Let's now call the function we created above loadsb(); //Slimbox is now loaded. }); }); &lt;/script&gt; </code></pre> <p>Also, please note: Now that we have to manually load slimbox, it will not work just by including the JS file in a page. you will have to use the Function declaration and call whenever you wanna load SB. (or just move the functon declaration to slimbox.js file and call it once in that file itself.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload