Lately it seems like Impromptu has been growing at a pretty rapid pace, and much of the reason behind it are community contributions and the fact that I’m using it nearly every day. I realize there are pro’s and con’s to moving at a fast pace, which is why I’ve done my best to maintain backwards compatibility. That being said I’m taking suggestions on a 2.7 release. I’ve already had a few suggestions, and a few features I want to add myself. Feel free to add to the list, and we’ll see how the fit in.
- $.prompt.getCurrentState() – a method to return the current state being shown. I’m not sure yet whether to return the entire state(including buttons), or just the message area.
- $.prompt.getCurrentStateName() – would return a string, the name of the current state being shown.
- option.timeout – an option that would automatically close the prompt after X milliseconds(maybe after X seconds.. who knows..)
- option.url – an option to GET content from a remote file.
Also if all goes well, there might be an awesome new example/project using Impromptu in the near future. But I can’t tell you what it is yet! ;)
Related posts:


14 Responses
Sercan Virlan
15|Jun|2009 1Transferring data to callback function with extra parameter maybe will be nice
Sercan Virlan
15|Jun|2009 2ah sorry i transferred the data with form element but that can be more easy a data array to callback function
BenHen
15|Jun|2009 3Yeah!! Impromptu 2.7 out!!
“timeout
The number of milliseconds until the prompt automatically closes. Default: 0″
Coooool :) Thx trent!!
trent
15|Jun|2009 4BenHen,
Haha, you beat me to the draw, I put it out last night and was going to post the news this morning.
Sercan Virlan,
I’m not sure if I understand what you’re asking. There are currently 3 callback parameters:
v = value of the button that was clicked
m = message object(jquery object)
f = key/value pairs of all form fields at the time the prompt was submitted
is the f parameter the one you’re looking for?
Zsolt
16|Jun|2009 5Hi. Foremost I have to say that this plugin is awesome. I was looking for ages for this. Thx.
I would add an option to draw shadow behind the div.
Sercan Virlan
19|Jun|2009 6@trent
i solved my problem thanks
automatically closing is very nice so
Richard Chamorro
07|Aug|2009 7Hello,
How do can I have a button with spaces in it’s name? That would be a great improvement for me.
I would like to do something like this:
var okText = “Very good!”;
var cancelText = “Not bad”;
$.prompt(“Your ranking?”, { buttons: { okText: 1, cancelText: 0 }});
That doesn’t work…
trent
07|Aug|2009 8Hey Richard,
You can have spaces in the name. You will need to do it like so:
var mybtns = {};
mybtns['bla bla'] = true;
mybtns['more text'] = true;
$.prompt(‘my text here, { buttons: mybtns });
Hope that helps!
Jason DiMeo
04|Oct|2009 9Hello,
First off, I love the plug-in. Excellent work!
I have 1 small problem I am trying to figure out.
I have a form that when submitted, I use impromptu to ask the user a question. At that point, the user has the opportunity to cancel their submit or click ok to continue. Since impromptu returns the object instead of the value of the button the user clicked, I have no way to pass the value back to the form.
If the submit button has already been clicked, how can I return the value to the calling function ($(document).submit())? Any ideas?
$(document).submit(function() {
var validForm = false;
var confirmMsg = ’some msg’;
// validation code
if (validForm) {
$.prompt(confirmMsg, {
buttons: {Ok: true, Cancel: false},
callback: function(val) {
// want to return the value back to continue or cancel submit
return val;
}
});
}
});
trent
05|Oct|2009 10Hey Jason,
Because there is no way to stop javascript execution other than a native alert or confirm, you will not be able to successfully return a value like this. You will have to use the callbacks to complete your logic, or simply call a function passing it the value of the button clicked.
Another way to accomplish your confirm before submitting the form is to return false on the click event for the submit button(no matter what..), but then open up the confirm box and if Ok is clicked do something like:
$(‘#myForm’).submit();
Jason DiMeo
06|Oct|2009 11Thanks for the advice Trent!
That’s pretty much what I figured I would have to do to get around the issue. Not really an issue, just need to re-work my logic. Instead of using the $(document).submit() event, I simply have a custom function I use to handle the submit if the form validates.
Thanks again for your time.
J
steve
24|Nov|2009 12Hi Trent, thanks for this great plugin. I’m having a bit of difficulty implemting a callback tho and hoped you might be able to point me in the right direction. Here is a code snippet -
var frame = {
state0: {
html: ”,
buttons: { Cancel: false, Save: true },
focus: 1,
submit: function(v, m, f) { return true; },
callback: mycallbackform
}
};
function mycallbackform(v, m, f) {
$.prompt(‘ i clicked ‘ + v);
}
As you can see the callback code is from your example, I’m just trying to get the callback to work for now but with no luck. I know I’m missing something, any suggestion?
TIA
Steve
trent
24|Nov|2009 13Hey steve,
the callback function is sort of an overall option, not a ‘per state’ option since it is called once the prompt is closed no matter what state it was on. Try this:
$.prompt(frame, { callback: mycallbackform });
steve
24|Nov|2009 14Thanks Trent, works like a charm! I wondered if it had something to do with the ’state’ but wasn’t sure. really great plugin, thanks :)
Leave a reply