Topic: Replace confirm dialogs by default with JQuery.dialog()

Hi everyone!!

I'm starting with JQuery on Rails but I have a doubt and not as resolve, I hope you can help me...

The fact is that I want to replace the default dialog boxes that the browser shows me (when, for example, try to delete a register and shows me the dialog asking for confirmation) by the available in the library jQuery UI (dialog), but not how to do Javascript reference them from your class because or do not know if id they have it and therefore do not know what switch to use...

I refer specifically to the dialog boxes that show with ": confirm =>'...?'"

If someone has had this problem and knows a solution would appreciate much your cooperation.

Greetings!

Last edited by Garyto (2011-06-26 20:43:58)

Re: Replace confirm dialogs by default with JQuery.dialog()

In Rails3 you would use jquery-ujs.  I suggest you examine the code (it has a config option to use any custom confirm dialog). See: https://github.com/rails/jquery-ujs/blo … c/rails.js at around line 88 (as of now).

Re: Replace confirm dialogs by default with JQuery.dialog()

Thanks in advance smile
We are developing an application using Rails 3,JQuery and MYSQL.
We have gone through the github code but we are not able to replace the default dialog boxes.
Can you please provide some help to replace confirm in rails.ujs with JQuery UI Dialog ?

Re: Replace confirm dialogs by default with JQuery.dialog()

In your application.js (or wherever) insert:

$(document).ready(function(){
  $.rails.confirm = function(message) {
      return my_custom_confirm_dialog_function(message);
  }
});

my_custom_confirm_dialog_function(message) has to return true or false depending on the user's confirmation intent.

Last edited by boomerang (2011-07-11 17:54:37)