autosubmit method

This commit is contained in:
vitalets
2012-11-30 18:48:42 +04:00
parent 49d795bf0d
commit ed836c2271
6 changed files with 64 additions and 20 deletions

View File

@@ -127,7 +127,14 @@ To create your own input you should inherit from this class.
**/
escape: function(str) {
return $('<div>').text(str).html();
}
},
/**
attach handler to automatically submit form when value changed (usefull when buttons not shown)
**/
autosubmit: function() {
}
};
Abstract.defaults = {

View File

@@ -112,7 +112,15 @@ $(function(){
activate: function() {
this.$input.find('input[type="checkbox"]').first().focus();
}
},
autosubmit: function() {
this.$input.find('input[type="checkbox"]').on('keydown', function(e){
if (e.which === 13) {
$(this).closest('form').submit();
}
});
}
});
Checklist.defaults = $.extend({}, $.fn.editableform.types.list.defaults, {

View File

@@ -95,7 +95,16 @@ $(function(){
clear: function() {
this.$input.data('datepicker').date = null;
this.$input.find('.active').removeClass('active');
}
},
autosubmit: function() {
this.$input.on('changeDate', function(e){
var $form = $(this).closest('form');
setTimeout(function() {
$form.submit();
}, 200);
});
}
});

View File

@@ -112,7 +112,16 @@ $(function(){
clear: function() {
this.$input.datepicker('setDate', null);
}
},
autosubmit: function() {
this.$input.on('mouseup', 'table.ui-datepicker-calendar a.ui-state-default', function(e){
var $form = $(this).closest('form');
setTimeout(function() {
$form.submit();
}, 200);
});
}
});

View File

@@ -45,7 +45,13 @@ $(function(){
text = item.text;
}
Select.superclass.constructor.superclass.value2html(text, element);
}
},
autosubmit: function() {
this.$input.on('change', function(){
$(this).closest('form').submit();
});
}
});
Select.defaults = $.extend({}, $.fn.editableform.types.list.defaults, {