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

Confirm with Alert in result #147

Closed
christatedavies opened this issue Jul 3, 2013 · 9 comments
Closed

Confirm with Alert in result #147

christatedavies opened this issue Jul 3, 2013 · 9 comments

Comments

@christatedavies
Copy link

I have a confirm which, in turn calls an ajax call, and if the ajax call returns something invalid, an alert is shown.

The confirm works fine, but the alert flashes up and then disappears without me being able to read it.

Cut down version of the code here: http://pastebin.com/uW4Z8W9i

I have replaced the alertify alert, with a standard alert and I get the result I require but without the nice look... I'd love to be able to resolve this and have an alertify alert.

This is running in Chrome 27.0, on alertify v3.9

@fabien-d
Copy link
Owner

fabien-d commented Jul 3, 2013

This seems like it may be an event bubbling issue. I remember having something similar with chaining alertify dialogs but has been fixed.

Instead of using event.stopPropagation() try replacing it with event.preventDefault() and/or a return false at the bottom of the function.

Since the .live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live events

^ from the jQuery docs. And the live() method simply calls the on() method.

If that doesn't work - could you try providing a working demo?

I've tried calling, on the docs page, an alert dialog after the confirm without issues (w and w/o delay)

alertify.confirm('test', function (e) {
    if (e) {
        setTimeout( function () { alertify.alert('blah'); }, 1000);
    } else {
        alertify.alert('cancel');
    }
});

@christatedavies
Copy link
Author

Still can't get it to work.

Here is a 'non' working example:

http://jsfiddle.net/5HygY/3/

On 3 July 2013 13:31, Fabien Doiron [email protected] wrote:

This seems like it may be an event bubbling issue. I remember having
something similar with chaining alertify dialogs but has been fixed.

Instead of using event.stopPropagation() try replacing it with
event.preventDefault() and/or a return false at the bottom of the
function.

Since the .live() method handles events once they have propagated to the
top of the document, it is not possible to stop propagation of live events

^ from the jQuery docs. And the live() method simply calls the on()method.

If that doesn't work - could you try providing a working demo?

I've tried calling, on the docs page, an alert dialog after the confirm
without issues (w and w/o delay)

alertify.confirm('test', function (e) {
if (e) {
setTimeout( function () { alertify.alert('blah'); }, 1000);
} else {
alertify.alert('cancel');
}});


Reply to this email directly or view it on GitHubhttps://github.com//issues/147#issuecomment-20412093
.

@fabien-d
Copy link
Owner

fabien-d commented Jul 3, 2013

Could you confirm if this is only happening using the keyboard? It's the only way I have been able to reproduce...

I haven't been able to reproduce in 0.4.0rc1 (keyboard or mouse), so I'll see about implementing the fix in 0.3.*.

@christatedavies
Copy link
Author

I can confirm it doesn't work with either the mouse or the keyboard.

The jsfiddle will show you it not working. I may have done something incorrect... The button on the jsfiddle is only clickable once, which is odd...

@fabien-d
Copy link
Owner

fabien-d commented Jul 3, 2013

the clicking once is another issue - there is a temporary fix at issue #138.

So there is a bug in the alertify code. In the hide method, I set isOpen to false immediately and I believe since there is a small delay between the ajax request and the next call, the new dialog gets confused for the existing one and also closes.

I'll have to dig a bit more and tweak some of the functionality around this.

@christatedavies
Copy link
Author

Would it be better if I upgraded to version 4? I think you said you fixed
it in that?

On 3 July 2013 14:56, Fabien Doiron [email protected] wrote:

the clicking once is another issue - there is a temporary fix at issue
#138 #138.

So there is a bug in the alertify code. In the hide method, I set isOpento false immediately and I believe since there is a small delay between the
ajax request and the next call, the new dialog gets confused for the
existing one and also closes.

I'll have to dig a bit more and tweak some of the functionality around
this.


Reply to this email directly or view it on GitHubhttps://github.com//issues/147#issuecomment-20416659
.

@fabien-d
Copy link
Owner

fabien-d commented Jul 3, 2013

I wasn't able to reproduce - but I haven't tested it with your example so I can say for sure it will work.

0.4 is in release candidate, so it hasn't been fully tested and it's a completely new API (can't just swap 0.3 for 0.4). You can see the demo site and see if you want to give it a go.

I'm hoping to get more time to work on alertify and get 0.3 stable and then leave it as a legacy as I bring 0.4 stable and onto a 1.0

@fabien-d
Copy link
Owner

fabien-d commented Oct 8, 2013

Sounds similar to #166. Should be fixed with #176 which will be in 0.3.11

@christatedavies
Copy link
Author

I've just checked my non working demo and it seems to work fine now. A little bit strange as I am hosting the JS file myself and I haven't changed it.

Anyway, it works, so I'm closing this issue.... Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants