fn ctrlEnter function ajax options return this each function this bind

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
$.fn.ctrlEnter = function(ajax, options){
return this.each(function(){
$(this).bind('keyup', function(event){
if(event.keyCode == 13 && event.originalEvent.ctrlKey){
if(ajax){
$(this.form).ajaxSubmit(options);
} else {
this.form.submit();
}
}
});
});
}
//Example
//Для всех textarea
$('textarea').ctrlEnter();
$('textarea').ctrlEnter(true, {/* options for jquery forms */});