Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggering rewritten #32

Closed
lukeshumard opened this issue Apr 14, 2011 · 5 comments
Closed

Triggering rewritten #32

lukeshumard opened this issue Apr 14, 2011 · 5 comments

Comments

@lukeshumard
Copy link
Contributor

I've been thinking more and more how awesome it would be to rewrite triggering of events in the plugin. Right now, triggering the plugin to pause would be written as...
$(window).trigger('pause.infscr'); or $(window).trigger('pause.infscr', ['pause']);

What I'd like to do is modify this to...
$('#selector').infinitescroll('pause');

Aside from just being much more intuitive to write, maybe this could free up some of the bindings. Whenever I look at the code I can't help but think how sloppy that bit is.

My only concern is passing in arguments to this. This could be done with the . character, so the syntax would be...
$('#your-selector').infinitescroll('method.argument');.

Thoughts, ideas, feedback, etc. appreciated!

@samcleaver
Copy link
Contributor

I think the way you suggest is correct; the jQuery docs themselves suggest this kind of format (which is along the lines of your suggestion):


$('div').infinitescroll(); // calls the init method
$('div').infinitescroll({  // calls the init method
  foo : 'bar'
});
$('div').infinitescroll('pause'); // calls the pausemethod
$('div').infinitescroll('stop', 'A variable to pass along'); // calls stop method and ending message

Obviously the idea is to make the plugin as modular as possible, i.e. we could add other methods at a later date.

@ghost ghost assigned lukeshumard Apr 14, 2011
@lukeshumard
Copy link
Contributor Author

Perfect. I should have this done in a few hours or by tomorrow morning (London time).

@lukeshumard
Copy link
Contributor Author

Pretty sure this is in the bag.

I'll be testing this thoroughly tomorrow, but I think this also justifies a version to update 1.6. Once tested properly, I'll be pushing it to the repo.

http://pastebin.com/sayvVEm4

@lukeshumard
Copy link
Contributor Author

Boom, this is done. The only thing we don't have support for is where options are blank, like so...

$('#your-selector').infinitescroll()

I can add this in, but not sure if it's a good idea. I have a feeling it would cause a flood of issues for 'why doesn't this work?' when the plugin/markup hasn't been setup properly.

@paulirish
Copy link
Contributor

+1 !!!!

@lukeshumard lukeshumard removed their assignment Feb 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants