Reputation: 334
I'm trying to run a dojo
(searchNotFound) if another dojo of searching (searchDlg) not finding result
So, the dojo (searchNotFound) is up , but not focusing on OK
(cause I've an event onkeypress
on this Button OK)
So, this is my code :
Function FindString() :
function findString(str) {
//Some Code
//if serach not founding , running dojo searchNotFound
if (!strFound) {
dojo.widget.byId("searchDlg").hide();
dojo.widget.byId("searchNotFound").show();
dojo.byId("searchnotfound_close").focus(); --> ****** not working ******
}
}
OnKeyPress event on OK Button (searchnotfound_close) of dojo (searchNotFound) :
--> Works Fine
<button class="btn dlg" id="searchnotfound_close" onkeypress="javascript:closeSearchNotFound(event)"><span key="ok">Ok</span></button>
Function closeSearchNotFound(event)
--> Works Fine
//#96985
function closeSearchNotFound(event) {
if(event.which == 13){
dojo.widget.byId('searchNotFound').hide();
dojo.widget.byId('searchDlg').show();
}
}
//
See This test video : https://www.youtube.com/watch?v=cM4rCtP7REA&feature=youtu.be
Upvotes: 1
Views: 295
Reputation: 302
I'm assuming 'searchNotFound' is a dijit/Dialog. show() is asynchronous because it shows the dialog with an animation. Because of that, show() returns a dojo/promise/Promise. Once the promise completes, the dialog is fully rendered and your subsequent search should work.
Use the promise and register your own callback:
registry.byId("searchNotFound").show().then(
function() {
dojo.byId("searchnotfound_close").focus();
});
Upvotes: 1