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

Comments

Projects
None yet
2 participants
@Blackskyliner
Contributor

Blackskyliner commented Oct 17, 2014

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

This comment has been minimized.

Show comment
Hide comment
@nyroDev

nyroDev Oct 17, 2014

Owner

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

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

This comment has been minimized.

Show comment
Hide comment
@Blackskyliner

Blackskyliner Oct 17, 2014

Contributor

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.

Contributor

Blackskyliner commented Oct 17, 2014

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

This comment has been minimized.

Show comment
Hide comment
@nyroDev

nyroDev Oct 17, 2014

Owner

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

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 nyroDev closed this in b7ae3ac Oct 17, 2014

@nyroDev

This comment has been minimized.

Show comment
Hide comment
@nyroDev

nyroDev Oct 17, 2014

Owner

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.

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