bluerail / twitter-bootstrap-rails-confirm

Confirm dialogs using Twitter Bootstrap
https://bluerail.nl
MIT License
85 stars 34 forks source link

Static confirm call #12

Closed gdlx closed 11 years ago

gdlx commented 11 years ago

More a question than an issue : is there a way to send a static call to confirm function with your override features enabled ?

I mean, I need to call confirm after an ajax response but if I just call confirm or even $.rails.confirm (I thought your gem was overriding it), I get browser's basic confirm box.

I know I could call TwitterBootstrapConfirmBox explicitely but I don't want my ajax function to depend on a specific gem. So it should call a "standard" conrifm function, and use yours if present.

Thanks !

rvanlieshout commented 11 years ago

Rails calls $.rails.allowAction for that, so you could just call $.rails.allowAction(element).

gdlx commented 11 years ago

Ok but that means that I need an element with a confirm data attribute, which is not my actual case (and creating a hidden element just for the confirm call is not really clean...)

I understand that you've overridden the allowAction function but shouldn't you have overridden the root $.rails.confirm function so that all rails confirm calls are catched? (you currently only catch action confirmations)

Additionally, it seems that you've just catched the click action...but I've no click action at all...just an ajax callback...

gdlx commented 11 years ago

I tried to override $.rails.confirm but it doesn't seems to be possible to it in a clean way with the same behavior (bool return, no callback) because JS execution is not suspended while confirm box is displayed...