Without further delay I am pleased to present to you jQuery Impromptu 2.6. I’ve implemented a few features requested by users, and they were all much needed. The new features include:
- Fix iframe to work better with secure sites
- Constrain tabs to within prompt. No more tabing onto the page beneath the prompt
- Option to make the fade persistent. If option persistent is set to false the prompt will close when the fade is clicked.
The persistent feature was already there, but kind of hidden. A user requested it so I double checked. I’ve tested the tab feature on IE 6, 7, FF, Chrome, Opera, Safari (Win) and all works fine! Enjoy!
Related posts:


24 Responses
Sercan Virlan
30|May|2009 1Hello
ive an idea for your project
everythings ok but auto closing in one ,two secons can be possible ?
trent
01|Jun|2009 2I might add an option for this, good idea..
Guilherme Cardoso
02|Jun|2009 3Hi,
I’m using it in a project of a ecommerce package to warn users about failed logins, erros in validate inputs, etc.
I really like it.
Congragulations for your project.
Ray
02|Jun|2009 4Only problem i have with this plugin which is stopping me from using it, is that i can’t specify a URL to show int he dialog.
Fix that problem and you will have a plugin that can compete against Thickbox.
trent
03|Jun|2009 5Right now Impromptu doesn’t do that, and seems to be a little out of scope for the upcoming release, however its pretty easy to accomplish:
$.get(‘myfile.php’,{},function(data){
$.prompt(data);
});
-trent
trent
03|Jun|2009 6I will put it on my to do list though and see how it works in
Jon Anderson
21|Jul|2009 7Okay Trent, I really need some help :)
Currently I’m using Imp to pop up a box, and false/no moves the user to a new page, true/yes just closes the prompt.
Well, I need it to do more.
Rather than using onload when a user enters the page (to pop up the box), rather I need to pop up the box when a link is clicked on the page. Then if false/no, pass to the original link noted in the script as before. If true/yes, rather than just closing the prompt I need it to pass the user along to the link noted in the onclick a href.
SO:
Here’s the script right now –
function load()
{
$.prompt(‘Are you able to sign in to your account?You\’ll need to sign in to submit a support ticket.’,{ buttons: { Yes: true, No: false },
callback: function(v,m,f){
if(v == false){window.location = “page2.html”;
}
}
});
}
And here’s an example link that doesn’t work:
Page1
So if the user clicks the link, they should get the prompt. If they answer yes, they move on to page1.html. If they answer no, they get page2.html.
There are 6 links like this that go to 6 different pages.
Any help you can give would be much appreciated!!
Jon Anderson
21|Jul|2009 8That link didn’t show up right. Will try again:
trent
21|Jul|2009 9A few steps to get this working. First assign click action, but return false initially. We’ll determine later whether to forward to the link’s url:
$(function(){
$(‘a.mylink’).click(function(){
var linkurl = $(this).attr(‘href’);
$.prompt(‘text’,{buttons:btns, function(v,m,f){
if(v) { window.location = linkurl; }
else { }//do something different
}
});
return false; //automatically return false
});
});
Jon Anderson
21|Jul|2009 10Thanks Trent, but I’m not sure what to do with this. I’m a bit of a noob but learning a lot. Does this get added before all the other JS?
trent
21|Jul|2009 11You were close in your attempt. The only thing I did different is use jquery’s load and click events.
This is jquery’s short hand for page load event:
$(function(){
});
Then I found the link you were looking for (you will need to change the selector for your needs):
$(‘a.mylink’).click(function(){
return false; // this will cancel the click event
});
place the $.prompt call inside taht click event. (your previous prompt looks like it should work).
This can be added anywhere after your jquery include. Then by using the load event that code will not execute until everything is loaded.
Jon Anderson
21|Jul|2009 12Hmmm…I think I get it. I’m at the “cut/paste to show me” kind of stage, so it’s going to be a bit of trial and error to get it working :)
Thanks again, but keep an eye out for my cries of help…
Jon Anderson
21|Jul|2009 13Nope, too much for me: I just don’t get it.
I think I get how to include the prompt event, but I have no idea what the main script is supposed to look like, or how it’s supposed to find my links.
The only way I’m really going to understand this is to see the whole thing, the way it’s supposed to look as pasted in the HTML.
I’m learning a lot, but just not there yet!
Jon Anderson
21|Jul|2009 14Maybe I’m confused because it’s not trying to do the right thing? It’s supposed to go to one page on true, and another page on false. The page it goes to on true varies depending on which link they click (which is why I assume the prompt is going to be in the actual onclick event rather than in the main script.)
There should never be a case where the prompt is simply dismissed.
trent
21|Jul|2009 15Try this. in your link tag add a class called “imp_event”:
<a href=”http://google.com” class=”imp_event” rel=”nofollow”>Click Here</a>
Then anywhere after that add this:
<script type=”text/javascript”>
$(function(){
$(‘a.imp_event’).click(function(){
$.prompt(‘Hello World’);
return false;
});
});
</script>
This should stop the link from forwarding and throw up the prompt. This is for starters.. so it doesnt do exactly what you want yet..
Make sure you have jquery included in your page in the head section.
trent
21|Jul|2009 16be sure to replace any weird ‘ or ” with true single or double quotes.. the blog likes to make the funny characters..
Jon Anderson
21|Jul|2009 17Okay, stupidness. Probably important to have jquery load first.
Now your sample works.
Jon Anderson
21|Jul|2009 18I added in your script (top) and just did a simple “hello world” test on the link and it works fine (thank you!). The problem now seems to be my more complex prompt for false in the onclick event. can’t get it to do anything..
trent
21|Jul|2009 19Ok, now you can just add some buttons to Impromptu and handle the event accordingly. First we need to get the url in the link that was clicked. So just before the $.prompt add this:
var linkurl = $(this).attr(‘href’);
Now we will replace the $.prompt with one more complex:
$.prompt(‘Hello World!’,{buttons:{Yes:true,No:false}, function(v,m,f){
if(v) { window.location = linkurl; }
else { window.location = “http://yahoo.com”; }//do something different
}
});
leave everything else the same.
Jon Anderson
21|Jul|2009 20Got it! Woo! Thanks..
Jon Anderson
21|Jul|2009 21Ended up with this at top:
$(function(){
$(‘a.popup’).click(function(){
var linkurl = $(this).attr(‘href’);
$.prompt(‘Are you able to sign in to your account?You\’ll need to sign in to submit a support ticket.’,{ buttons: { Yes: true, No: false },
callback: function(v,m,f){
if(v == false){window.location = “page1.html”;
}
else { window.location = linkurl;; }
}
});
return false; //automatically return false
});
});
And links looking like:
Page 2
Jon Anderson
21|Jul|2009 22Uh…minus the extra semi-colon :)
trent
21|Jul|2009 23so you got it to work? Sorry I noticed I had a couple small errors, but looks like you caught them.
Jon Anderson
21|Jul|2009 24Yep, I was plucking away at it while waiting for your answer. Learned a lot in a short time. Thank you again!
Leave a reply