提交 eff999d6 编写于 作者: E Erik St. Martin

initial prototype of jQuery driver complete

上级 a0232d86
// TODO: confirm
// TODO: popup
// TODO: disable_with
jQuery(function ($) {
var rails = {
update: function (selector, content, position) {
......@@ -76,6 +73,21 @@ jQuery(function ($) {
}
},
complete: function (xhr) {
// enable disabled_with buttons
if (el[0].tagName.toUpperCase() == 'FORM') {
el.children('input[type="button"][data-enable-with],input[type="submit"][data-enable-with]').each(function(i, button){
button = $(button);
button.attr('value', button.attr('data-enable-with'));
button.removeAttr('data-enable-with');
button.removeAttr('disabled');
});
} else {
el.attr('value', el.attr('data-enable-with'));
el.removeAttr('data-enable-with');
el.removeAttr('disabled');
}
el.trigger('rails:complete', xhr);
el.trigger('rails:loaded', xhr);
},
......@@ -121,7 +133,7 @@ jQuery(function ($) {
* confirm
* make sure this event is first!
*/
$('a[data-confirm],input[data-confirm]').live('click', function(e){
$('a[data-confirm],input[type="submit"][data-confirm],input[type="button"][data-confirm]').live('click', function(e){
var el = $(this);
if(!confirm(el.attr('data-confirm'))){
......@@ -146,6 +158,17 @@ jQuery(function ($) {
}(e, el), frequency * 1000);
});
/**
* disable_with
*/
$('input[type="button"][data-disable-with],input[type="submit"][data-disable-with]').live('click', function(e){
var el = $(this);
el.attr('data-enable-with', el.attr('value'));
el.attr('disabled', 'disabled');
el.attr('value', el.attr('data-disable-with'));
});
/**
* remote_form_tag, and remote_form_for
*/
......@@ -159,7 +182,7 @@ jQuery(function ($) {
/*
* popup
*/
$('a[data-popup],input[data-popup]').live('click', function(e){
$('a[data-popup],input[type="button"][data-popup]').live('click', function(e){
var el = $(this),
url = el.attr('data-url') || el.attr('href');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册