开发者

How to replace default dialog boxes in Rails 3 with JQuery UI Dialog?

开发者 https://www.devze.com 2023-03-17 19:57 出处:网络
We are a startup working on an application and we are using Rails 3 and JQuery as our technology. 开发者_如何学编程We need help to replace default confirm dialog boxes in rails.ujs with JQuery UI Dial

We are a startup working on an application and we are using Rails 3 and JQuery as our technology. 开发者_如何学编程We need help to replace default confirm dialog boxes in rails.ujs with JQuery UI Dialog.


This certainly requires some work that is not made "out of the box". You have to understand the basics of what you are asking.

First of all, you click on a link that has :confirm => "Are you sure?", which adds the data-confirm attribute to your html tag. Then, you have a event listener binded on all elements which have a data-confirm attribute, and simply does a confirm of the attribute value ("Are you sure?"). If the user click yes, nothing happens, which means that the link is followed. If the user click cancel, the event is cancelled and the link is not followed.

What you want to do is to break this behavior. You want to store whatever action was called, cancel the current event. Then, use the jquery dialog, and depending on the user choice, call that action again or do nothing.

You can't simply replace the confirm with a jquery dialog because the browser won't wait for the jquery dialog answer, as it does for the confirm box.

Hope that helped you understand the basic of what you are going to implement.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号