EasyUI Forum
September 13, 2025, 10:58:55 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: syncronous prompt window / messager  (Read 9299 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: January 28, 2015, 07:21:48 PM »

I need a synchronous dialog / window that allows me to have a few input elements for user input, rather than just one single element as per the jajascript prompt().

Can this be done ? - I need a callback once thse user clicks OK, but I also need to show a couple of comboboxes and inputs and return the data when the user clicks OK

 
Logged

-- Licensed User --
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #1 on: January 28, 2015, 07:38:47 PM »

Can the messager prompt be modified so that it parses the inputs in the dialog into a json string and sends that back as a single variable ?
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: January 28, 2015, 08:28:39 PM »

Defining a customized dialog to achieve this functionality may be more appropriate.
Code:
function showPrompt(title, href, fn){
var dlg = $('<div></div>').appendTo('body').dialog({
width: 300,
height: 150,
title: title,
href: href,
modal: true,
buttons:[{
text: 'Ok',
handler: function(){
var d = $(this).closest('div.panel').find('div.panel-body');
var json = d.find('form').serialize();
fn(json);
d.dialog('destroy');
}
},{
text: 'Cancel',
handler: function(){
var d = $(this).closest('div.panel').find('div.panel-body');
d.dialog('destroy');
}
}],
onClose: function(){
$(this).dialog('destroy');
}
}).dialog('dialog').find('.dialog-button').css('text-align','center')
}

Usage example:
Code:
showPrompt('Prompt', '_form.html', function(json){
  console.log(json);
});
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #3 on: January 29, 2015, 02:23:40 AM »

Thanks, but what I am looking for is something similar to the standard javascript prompt() which freezes the calling script execution until a reply is received.

Using a callback from a normal window means that the calling code continues to run after the dialog is called.

Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: January 29, 2015, 07:52:24 AM »

The $.messager.prompt and the 'showPrompt' functions work asynchronously. The user can not pause the code executing after calling these functions.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!