Tuesday, August 19, 2008

save_tag to avoid multiple click in IE and Firefox

##############################################################################
# Overrides sumit_tag for disable save after click event --JAGAN REDDY
##############################################################################
def commit_tag(value,options={})
options.stringify_keys!
submit_tag value, options.merge(:onclick => '

if(window.addEventListener)
{
this.disabled = true;
}
else
{ // IE
// this.disabled = true;
setTimeout(m(), 10000);
}
function m()
{
// var tag = window.event.srcElement.tagName
this.disabled = true;
}')
end

use this in apllication_helper.rb

No comments: