ionfish
ionfish

Reputation: 171

How to use impromptu for Jquery to act like a confirm box

$('.delVid, .delUpdate, .delComment').click(function(){   //check deletions
  $.prompt('delete this entry?',{ buttons: { Ok: true, Cancel: false }, focus: 1 });
  return false;
});

The classes are describing hyperlinks that when clicked delete an entry from MySQL.
I was using a vanilla confirm box before and having success, but I don't understand how to return a "true" or "false" from the impromptu box.
I think I have to use some kind of callback function, but I have been having no success =/

Upvotes: 1

Views: 2807

Answers (1)

jkfuyaflkjd
jkfuyaflkjd

Reputation: 682

If you check out this link:

http://trentrichardson.com/Impromptu/index.php

It shows you on the RH column about 50% way down your answer. Here it is anyway:

Add a callback function:

function mycallbackfunc(v,m,f){
    $.prompt('i clicked ' + v);
}

$.prompt('Example 8',{ callback: mycallbackfunc });

The callback function has three parameters.

  • The first is the value of the button clicked.
  • The second is a jQuery object of the message within the active state when the user clicked the button. The third is an object of key/value pairs of the form values.
  • The keys are the name attribute for the form element.

Upvotes: 2

Related Questions