focus on first element when dialog opens and enter on text triggers submit
This commit is contained in:
parent
9943615d03
commit
ebea2c1d4c
2 changed files with 17 additions and 3 deletions
|
|
@ -43,7 +43,7 @@ wn.widgets.form.sidebar = { Sidebar: function(form) {
|
|||
label: 'List',
|
||||
icon: 'icon-list',
|
||||
display: function() {
|
||||
return !me.form.meta.issingle;
|
||||
return !me.form.meta.issingle && !me.form.meta.read_only;
|
||||
},
|
||||
onclick: function() { window.location.href="#!List/" + me.form.doctype }
|
||||
},
|
||||
|
|
|
|||
|
|
@ -49,6 +49,15 @@ wn.widgets.FieldGroup = function() {
|
|||
}
|
||||
}
|
||||
|
||||
this.catch_enter_as_submit = function() {
|
||||
var me = this;
|
||||
$(this.body).find(':input[type="text"], :input[type="password"]').keypress(function(e) {
|
||||
if(e.which==13) {
|
||||
$(me.body).find('.btn-info:first').click();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* get values */
|
||||
this.get_values = function() {
|
||||
var ret = {};
|
||||
|
|
@ -119,8 +128,10 @@ wn.widgets.Dialog = function(opts) {
|
|||
|
||||
this.make_head();
|
||||
this.body = $a(this.wrapper, 'div', 'dialog_body');
|
||||
if(this.opts.fields)
|
||||
if(this.opts.fields) {
|
||||
this.make_fields(this.body, this.opts.fields);
|
||||
this.catch_enter_as_submit();
|
||||
}
|
||||
}
|
||||
|
||||
this.make_head = function() {
|
||||
|
|
@ -156,7 +167,7 @@ wn.widgets.Dialog = function(opts) {
|
|||
|
||||
// show it
|
||||
$ds(this.wrapper);
|
||||
|
||||
|
||||
// hide background
|
||||
freeze();
|
||||
|
||||
|
|
@ -165,6 +176,9 @@ wn.widgets.Dialog = function(opts) {
|
|||
|
||||
// call onshow
|
||||
if(this.onshow)this.onshow();
|
||||
|
||||
// focus on first input
|
||||
$(this.wrapper).find(':input:first').focus();
|
||||
}
|
||||
|
||||
this.hide = function() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue