Jquery-rails monkey patch
Since Rails 3, unconspicuous javascript(jquery-rails) instead of prototype.js to make thing easily. It provide a sample way to handle ajax, confirm, etc…
Sometimes jquery-rails couldn’t fit for our situation.For example:
With added “confirm: ‘this is is a confirm’”, the button element has the confirm function. But We could’t dynamically set the text whlie the confirm appear.
In this case, We can add a monkey patch into jquery-rails to fit for our need.
First of all We look at the source of juqery-rails, figure out what make this happened.
1 2 3 4 5 6 7 8 9 10 11 |
|
After that, We overwrite this function in application.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Finally, We can dynamically set the confirm text.