Set focus on the first enabled field when a dialogue is opened. Fixes #1533

REL-1_X
Surinder Kumar 2017-06-08 14:37:31 +01:00 committed by Dave Page
parent 01bfa88309
commit c9b717ed68
1 changed files with 10 additions and 4 deletions

View File

@ -294,6 +294,12 @@ define([
}); });
} }
var setFocusOnEl = function() {
setTimeout(function() {
$(el).find('.tab-pane.active:first').find('input:first').focus();
}, 500);
};
if (!newModel.isNew()) { if (!newModel.isNew()) {
// This is definetely not in create mode // This is definetely not in create mode
var msgDiv = '<div class="alert alert-info pg-panel-message pg-panel-properties-message">'+ var msgDiv = '<div class="alert alert-info pg-panel-message pg-panel-properties-message">'+
@ -306,6 +312,7 @@ define([
$msgDiv.appendTo(ctx); $msgDiv.appendTo(ctx);
} }
}, 1000, ctx); }, 1000, ctx);
newModel.fetch() newModel.fetch()
.success(function(res, msg, xhr) { .success(function(res, msg, xhr) {
// clear timeout and remove message // clear timeout and remove message
@ -315,9 +322,7 @@ define([
// We got the latest attributes of the // We got the latest attributes of the
// object. Render the view now. // object. Render the view now.
view.render(); view.render();
if (type != 'properties') { setFocusOnEl();
$(el).focus();
}
newModel.startNewSession(); newModel.startNewSession();
}) })
.error(function(xhr, error, message) { .error(function(xhr, error, message) {
@ -351,8 +356,9 @@ define([
}); });
} else { } else {
// Yay - render the view now! // Yay - render the view now!
$(el).focus(); // $(el).focus();
view.render(); view.render();
setFocusOnEl();
newModel.startNewSession(); newModel.startNewSession();
} }
} }