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

Opened and closed events #246

Closed
Blackskyliner opened this issue Oct 17, 2014 · 4 comments
Closed

Opened and closed events #246

Blackskyliner opened this issue Oct 17, 2014 · 4 comments
Labels

Comments

@Blackskyliner
Copy link
Contributor

It would be nice to have some events we could just grab with jQuery somehow.

  • modal-opened(sender) // sender is the element which opened the modal
  • modal-closed(sender) // sender is the original one which opened the modal

and maybe "advanced" ones like:

  • modal-redirect(target) // target uri, but I got no real use-case for this atm so its just more like an idea ;)

I know you got those callbacks for that, but they are kind of a hassle in moular js programming... where I got some late bind/execution of JS code etc.

@nyroDev
Copy link
Owner

nyroDev commented Oct 17, 2014

you mean trigger some events on the opener tag to indicates wher we are in the popin?

@nyroDev nyroDev added the Todo label Oct 17, 2014
@Blackskyliner
Copy link
Contributor Author

More like a global event like "hey there was an modal opened, if you are interested in doing whatever you want to do (like initializing some advanced java stuff inside the modal)".
The this argument for the callback would be the nm object like in callbacks.
The first agument would be the sender, or an event which has some source in it where the event originated from.

@nyroDev
Copy link
Owner

nyroDev commented Oct 17, 2014

As the events aer bubling from bottom to top, it should work as you excpect.
I'll try something and a basic demo

@nyroDev
Copy link
Owner

nyroDev commented Oct 17, 2014

You can see an example using it here: http://nyromodal.nyrodev.com/testBind.php

The code used show that you'll be able to bind directly on the opener, or in a more globaly place, in the body:

var csl = $('#console');

$('body').on({
    'init.nyroModal': function(e, nm) {
        csl.append('BODY: init<br />');
    },
    'load.nyroModal': function(e, nm) {
        csl.append('BODY: load<br />');
    },
    'afterShowCont.nyroModal': function(e, nm) {
        csl.append('BODY: afterShowCont<br />');
    },
    'close.nyroModal': function(e, nm) {
        csl.append('BODY: close<br />');
    }
});

$('.nyroModal').on({
    'init.nyroModal': function(e, nm) {
        csl.append('Element: init<br />');
    },
    'load.nyroModal': function(e, nm) {
        csl.append('Element: load<br />');
    },
    'afterShowCont.nyroModal': function(e, nm) {
        csl.append('Element: afterShowCont<br />');
    },
    'close.nyroModal': function(e, nm) {
        csl.append('Element: close<br />');
    }
}).nyroModal();

Every single call to the callFilter will be triggered, meaning that you can listen for every nyroModal event.

@nyroDev nyroDev added tips and removed Todo labels Oct 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants