jmpressjs / jmpress.js

A jQuery plugin to build a website on the infinite canvas
http://jmpressjs.github.com/jmpress.js
1.5k stars 237 forks source link

An onclick event to link next slide #51

Closed gho5twriter closed 12 years ago

gho5twriter commented 12 years ago

Hi i'm very new to jQuery and hope this is the right place to post my problem. I'm having some trouble making a simple link button to the next slide. I thought it would look like this:

$(".mylink").click(function(event){
    $('#featured').jmpress(next);
});

or like this

$(".mylink").click(function(event){
    $('#featured').jmpress('next');
});

But neither will select the next slide. Slide IDs are generated dynamically from my CMS so I can't hard code the URLs.

Thanks

sokra commented 12 years ago

The second one should do it.

featured is your jmpress container.

sokra commented 12 years ago

Maybe your code run before the link (.mylink) is loaded. It should on the ready event:

$(function() { // on document ready
  $(".mylink").click(function(event){
    $('#featured').jmpress('next');
  });
});
gho5twriter commented 12 years ago

Thanks for the quick response, but unfortunately it's still not working,

I am loading my scripts in this order in the header:

  1. jquery
  2. jmpress,
  3. main.js

my main js is as follows:

$(document).ready(function() {
    $(".mylink").click(function(event){
        $('#featured').jmpress('next');
    });
});

And I load jmpress in the footer

$(function() {
    $('#featured').jmpress({
    viewPort        : {
        height  : 400,
        width   : 920,
        maxScale: 1
    },
    fullscreen      : false,
    hash            : {use : false},
});
});

key and mouse navigation works fine also, any ideas?

Thanks for all the help

sokra commented 12 years ago

does the click event fire?

gho5twriter commented 12 years ago

yes i can fire an alert for example but nothing comes through for jmpress. Is there a way I can message you a url if it makes it easier?

sokra commented 12 years ago

that would be nice. you can send me a mail to [removed]

gho5twriter commented 12 years ago

ok thank you very much for all the help!

gho5twriter commented 12 years ago

For anyone reading this the issue was resolved by adding this after the method:

return false;

the problem was due to the link being on the slide.

The resulting code looks like this:

$(document).ready(function() {
    $(".mylink").click(function(event){
        $('#featured').jmpress('next');
        return false;
    });
});
Metalchocobo commented 12 years ago

Thank you very much for the solution. I had same problem with goTo.

martinferes commented 12 years ago

Thanks! I had the same problem too

gianca commented 11 years ago

Thanks for the solution guys! I had the same exact problem! this plugin rocks :-) !