Rails 3 remote link with :condition and mootools -
back in rails 2, there :condition option in link_to_remote let specify javascript had return true or remote request not send. however, in rails 3 seems options has been removed.
what want have ajax form, needs undergo validation on browser before gets submitted (this non-standard validation). need able set conditional javascript expression prevent form being submitted if validation fails - same :condition option rails 2. there way achieve same functionality again in rails 3?
i'm using mootools mootools version of rails.js. looked through mootools rails.js file , didn't see looked let me specify conditional javascript. missing something?
*note: looked through source default rails.js file written in prototype. in file there there following lines:
var event = element.fire("ajax:before"); if (event.stopped) return false; this looks in prototype version can stop request being sent listening "ajax:before" event , stopping event in listener. however, can't find in mootools rails.js code, maybe bug in mootools rails.js file?
link_to_remote deleted rails 3. it's link_to :remote => true now. , if want js validation, can use this:
<%= link_to "test", '/test', :id => "test-link", :remote => true %> and add validation in application.js (in example it's prototype. , it's not problem mootools guess):
document.observe("dom:loaded", function() { $('test-link').observe('click', function(event){ if your_validation_magic event.stop(); }); }); update: mootools has event too: https://github.com/kevinvaldek/mootools-ujs/blob/master/source/rails.js#l131
Comments
Post a Comment