Impromptu 3.1 is in the works now, and I plan to release it this week. As of now I am just looking to add a few features, so there are no real changes that should break any older versions. As of now I have 3 new changes/additions, one of which is a bug fix.
1) Add callbacks to nextState, prevState, and goToState functions.
2) Fix bug when cloning html for use like $(‘#selector’).prompt(); In the source I needed to pass withDataAndEvents in the clone statement if specified in the options.
3) Ability to pass an object as button title and values. I’ve had this question a dozen times I’m sure, and the solution is really simple: How do I pass a dynamic value for the button text. The issue comes in that the text for the button is the key of a key value pair { key: value } and at first it doesn’t seem possible. But you just have to declare your values before passing them to prompt like var button[key_variable] = true; I have now made it possible to pass an array of objects as the buttons:
$.prompt('some text'{
buttons: [
{ title: 'some complex title', value: 1 },
{ title: 'another complex title', value: 2 },
{ title: 'easy title', value: 3 }
]
});
I’ve tried to pull these changes out of the requested fixes and additions, although I may be missed some, if so please don’t hesitate to comment about it again.
Related posts:




5 Responses
simon
29|Mar|2010after i clicked several examples,those buttons never work again;but after i refreshed the demo page and do the same operation,they work fine.
by the way,i am using firefox 3.6
in firefox’s consol ,it displayed f is not defined in common.js
this is a great plugin,thank you.
trent
29|Mar|2010I think jQuery changed the way it calls serialize in 1.4. I may need to change this as well. f is the variable that contains all form values from the prompt, which uses serializeArray Thanks for reporting!
Brandon
31|Mar|2010In Example 9, if you hit the “X” button to close the dialogue, the script returns an error on line 11 of common.js, which prevents you from using the other examples until you refresh the page (on both IE8 and Firefox).
The error-causing function is below:
function mycallbackform(v,m,f){
$.prompt(v +’ ‘ + f.alertName);
}
This error occurs because f is null. If you change the function as below, it will work when the “X” button is clicked:
function mycallbackform(v,m,f){
if (f != null) $.prompt(v +’ ‘ + f.alertName);
}
trent
31|Mar|2010Ahhh, yes, good catch. Laziness on my part.
matasoy
20|Mar|2011thanks fot button title code, and Impromptu