views:

12

answers:

1

Hi everyone,

I am having a problem with impromptu and instances. I have two instances of impromptu, so when i call to close the first, the other closes too.

Is there any way to say to close one and no the other?

A: 

So I'm guessing you're using jQuery.prompt.close() ?

I've never used impromptu, but it seems to me that it isn't meant to support multiple instances that are open at the same time. You can tell as much by looking at the source.

http://trentrichardson.com/Impromptu/scripts/jquery-impromptu.3.1.js

Personally, I'd suggest you switch to a better designed prompt system, but if you really want to continue using that, you'll have to close them manually. This is the internal structure of the .close() call

$('#'+ $.prompt.currentPrefix +'box').fadeOut('fast',function(){
  $(this).remove();
});

Where currentPrefix is equal to:

$.prompt( 'test', { prefix: 'the_prefix' } );
$.prompt( 'test', { prefix: 'the_prefix2' } );

So if you wanted to keep the two instances separate, you'd just need to use two separate prefixes and them manually close them like:

$('#the_prefixbox').fadeOut('fast',function(){
  $(this).remove();
});
$('#the_prefix2box').fadeOut('fast',function(){
  $(this).remove();
});
BBonifield