rails / jquery-ujs

Ruby on Rails unobtrusive scripting adapter for jQuery
MIT License
2.61k stars 508 forks source link

Is there interest in making it possible to support non-blocking message popups in jQuery UJS? #260

Closed webmat closed 11 years ago

webmat commented 11 years ago

Hey guys,

I'm using $ UJS in a Cordova app (initially PhoneGap), and everything works ok.

However, since $ UJS uses confirm, I don't have much control on the title of the popups: example

Cordova offers a notification API with better customizability, but the call is non-blocking, as opposed to confirm.

So I'm currently working out a sensible way to use Cordova's non-blocking notifications by patching jQuery UJS. As I see it so far, all calls to $.rails.allowAction will probably have to be rewritten to pass callbacks for "Ok" and "Cancel", instead of doing it with an if (example).

Do you guys think that would be an interesting addition to jQuery UJS, or do you think this is out of scope for this project?

I'll come back and give more information on whatever solution I came up with.

Cheers,

Mat

JangoSteve commented 11 years ago

Yes, this is a very non-trivial undertaking (as everyone who has tried has discovered). The problem is that to get non-blocking confirm dialogs, it always breaks the blocking native version and vice versa. See #196 for related discussion, and my current working async branch, which provides this feature.

If enough people use that branch, I may consider merging it with master. It relies on some undocumented functionality in js/jquery, which is why I haven't pulled it in yet.

webmat commented 11 years ago

Excellent, thanks for your answer. I'll try this branch and report anything I find!