-1

I have an external Jquery code that looks like that :

jQuery(function($){
 $.supersized({
 navigation : 1, //Slideshow controls on/off
 thumbnail_navigation : 1, //Thumbnail navigation
 slide_counter : 1, //Display slide numbers
 slide_captions : 1, //Slide caption (Pull from "title" in slides array)
 slides : [
 {image : 'some/path', title : 'title'},
 {image : 'some/path', title : 'title'}, 
 {image : 'some/path', title : 'title'}
 ] //Slide Images to be specified on page
 }); 
});

Can I replace the 'slides' optio by some variable like $slide_urls and declare the image paths on individual html pages?

Felix Kling
820k181 gold badges1.1k silver badges1.2k bronze badges
asked Apr 9, 2011 at 17:03
0

2 Answers 2

1

As long as the variable $slide_urls is declared somewhere that would be visible inside the supersized() function and it is an array of objects, you can easily set it elsewhere in the page and have it referenced in your function:

$(window).ready(function(){
 $slide_urls = [ /* specific slides for the page */ ];
 // ... other code
 $.supersized({
 // other options
 slides: $slide_urls
 }
}
strager
90.4k27 gold badges139 silver badges181 bronze badges
answered Apr 9, 2011 at 17:10
Sign up to request clarification or add additional context in comments.

Comments

1

It would be possible if you declare slide_urls as global variable.

However, imo it is better to put this code in its own function and call it from the pages, passing in the right data:

// in your "external" code:
function setup(urls) {
 $.supersized({
 //...
 slides: urls
 });
}
// in the pages
$(function() {
 setup([/*...urls here...*/]);
});
answered Apr 9, 2011 at 17:12

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.