0

Located in a php page is the following code:

$(function() {
    $(".scrollable").scrollable({ items: "li", circular: true, mousewheel: false, next: ".next", prev: ".prev" }).autoscroll({autoplay: true, interval: 100});
});

This small slideshow is supposed to be able to scroll(rotate) images from left to right when the page loads. I don't know much about php, but shouldn't this code be enough to make the slideshow move on its own? (It does move when the user clicks on the left and right buttons)

If there is a better, faster, easier way to do this, I would really like some advice here. I have tried looking around, but any code that I find seems too complicated for this small of a task.

EDIT: I didn't create the page, so I don't know what this function is from. I'm looking in all the pages this is included in to see if I can find out where the javascript/jquery is being called.

ANSWER: The calls to the jquery were on another page that I had to find. But yeah, that was the problem! There was only one line of jquery that was called, not the 2 that were mentioned in the answer I chose. :/ Looks like someone started the pages, but never finished them.

Jamie
  • 1,579
  • 8
  • 34
  • 74
  • 1
    Looks like jQuery. Are you loading jQuery and the relevant scrollable plugin on the page before before trying to call it? – Billy Moat Oct 29 '12 at 17:06
  • Are you using jQuery TOOLS for the `.scrollable()` method? – 11684 Oct 29 '12 at 17:07
  • @11684 the console says `Uncaught ReferenceError: scrollable is not defined` – Jamie Oct 29 '12 at 18:20
  • Be sure to include that in your question always, for this is an important clue; it almost explicitly states that you forgot to import jQuery TOOLS. – 11684 Oct 29 '12 at 18:27
  • Ok thanks. It took a while to trace back to the original page because there are pages that include other includes pages and it gets confusing. But I found it and added the reference. – Jamie Oct 29 '12 at 19:03

1 Answers1

1

You need some CSS + jQuery + jQuery TOOLS plugin extension.

Just like this: http://jsbin.com/oviqap/1/edit

See http://jquerytools.org/demos/scrollable/index.html for further details

Anthony Hatzopoulos
  • 10,437
  • 2
  • 40
  • 57
  • One question, is there a way to randomize the images? I tried adding `random: 1` after `prev: ".prev"` but it didn't do anything. I also tried putting it after `interval: 1000` – Jamie Oct 29 '12 at 19:01
  • 1
    @jlg the plugin does not support random option. You'll need to either randomize the output using PHP before display or use more javascript to shuffle the DOM nodes around after load. Example [Shuffle DOM Elements](http://css-tricks.com/snippets/jquery/shuffle-dom-elements/) – Anthony Hatzopoulos Oct 29 '12 at 19:29
  • Hmm I wish I could vote for this answer twice! :D Thank you so much for helping out the n00b! – Jamie Oct 29 '12 at 22:07