Hi Dave,
Thank you once again! I think I am almost there. I have one other
issue. I am using ASP.Net and have code behind for each of 3 buttons.
I want the postback to fire the click event for the Delete button. If
I just use the form.submit() how will that cause the button click
event to fire? I see in the HTML generated by ASP.Net a __doPostback
function that seems to pass along the source of the postback. Perhaps
I need to call that routine in my onOkay function and pass the button
name as the __eventTarget.value?

TIA,
John

On Nov 17, 6:25 am, Fontzter <[email protected]> wrote:
> John,
>
> You need to have a click event for your delete button.  I'm assuming
> from your question that this button is a type="submit".  Basically,
> you want to prevent the default submit behavior and call it yourself
> based on the response to the prettyPrompt...something like this...
>
> $("#btnDelete").click(function(event)
> {
>      event.preventDefault();  //this stops the default submit behavior
> of the button
>      //now prompt and submit if needed
>      prettPrompt({
>          title: "Confirm Delete",
>          message: "Delete this item?",
>          cancelText: "No",
>          okayText: "Yes",
>          onOkay: function(){ $("#yourForm.submit(); } //this calls the
> submit programatically if user clicks okay
>      });
>
> });
>
> Hth,
>
> Dave
>
> On Nov 16, 10:33 am, john6630 <[email protected]> wrote:
>
> > Hi Dave,
> > Following up on my last post, which I think was not clear, I want to
> > ask will the following work:
>
> > btnDelete.Attributes.Add("onClick", "return prettPrompt({
> >     title: "Confirm Delete",
> >     message: "Delete this item?",
> >     cancelText: "No",
> >     onCancel: function(){ return False; },
> >     okayText: "Yes",
> >     onOkay: function(){return True; }
> >   });")
>
> > So I am adding prettyPrompt as the onClick function and waiting for
> > the user to make a selection and then returning True or False which
> > will either allow the form to be submitted or prevent the submit.
>
> > Thank you very much for your patience and help.
>
> > John
>
> > On Nov 15, 9:15 pm, john6630 <[email protected]> wrote:
>
> > > HI Dave,
> > > Thank you for all your help.Yes passing a function makes sense. Since
> > > I am new to JavaScript and JQuery, I hope you don't mind one more
> > > question. What I want to do is open the dialog on a submit button
> > > click. But not submit the form if the user selects "No" in the dialog.
> > > What it seems I need to do is attach prettyPrompt to the button click
> > > but somehow disable the button from actually doing the submit (can you
> > > advise how to do that) and then on the dialog "Yes" button use
> > > "window.document.myForm.submit()" as the function to cause the form to
> > > submit?
>
> > > TIA
> > > John
>
> > > On Nov 15, 10:26 am, Fontzter <[email protected]> wrote:
>
> > > > John,  It was designed with the intention of passing in the function
> > > > you want to execute.  So if you have a function called
> > > > whatToRunIfUserClicksOkay, you could simply pass it in as the onOkay
> > > > function...
>
> > > > onOkay: whatToRunIfUserClicksOkay
>
> > > > Hope that makes sense.
>
> > > > Dave
>
> > > > On Nov 13, 11:36 pm, john6630 <[email protected]> wrote:
>
> > > > > Hi Dave,
> > > > > That is perfect. I have on beginner question. Can I return True or
> > > > > False by simply putting "Return True" or "Return False" in the onOkay
> > > > > and onCancel functions? I want to use it in a button onClick = return
> > > > > PrettyPrompt so that if it returns false the onClick is canceled but
> > > > > if it returns true the onClick posts back to my codebhind.
>
> > > > > Hope that makes sense. And Thank YOU very much for the speedy and
> > > > > excellent response.
>
> > > > > John
>
> > > > > On Nov 13, 9:19 am, Fontzter <[email protected]> wrote:
>
> > > > > > Hi John,
>
> > > > > > Below is something I cobbled together a while back along with a few
> > > > > > examples of how I use it.  I have intentions to redo it, but it gets
> > > > > > the job done for now.  I put these examples up on jsbin too if you
> > > > > > want to see it in action:http://jsbin.com/etona/edit
>
> > > > > > You basically pass in 6 (all optional) parameters:
> > > > > > message: the message displayed,
> > > > > > title: the title displayed,
> > > > > > cancelText: text displayed on the cancel button,
> > > > > > okayText: text displayed on the okay button,
> > > > > > onCancel: a function to execute when the user clicks the cancel
> > > > > > button,
> > > > > > onOkay: a function to execute when the user clicks the okay button
>
> > > > > > Hth,
>
> > > > > > Dave
>
> > > > > > /*******************************************************************
> > > > > > * prettyPrompt - prompts the user with a okay/cancel prompt
> > > > > > ********************************************************************/
> > > > > > function prettyPrompt(options)
> > > > > > {
> > > > > >     var o = $.extend({ message: "Hello!", title: "Please Note...",
> > > > > > cancelText: "Cancel", okayText: "Okay", onOkay: null, onCancel:
> > > > > > null },options);
> > > > > >     var btns = {};
> > > > > >     btns[o.okayText] = function() { $(this).dialog("close"); if
> > > > > > ($.isFunction(o.onOkay)) o.onOkay(); };
> > > > > >     btns[o.cancelText] = function() { $(this).dialog("close"); if
> > > > > > ($.isFunction(o.onCancel)) o.onCancel(); };
> > > > > >     $("<div title='" + o.title + "'>" + o.message + 
> > > > > > "</div>").dialog({
> > > > > >         modal: true,
> > > > > >         buttons: btns,
> > > > > >         close: function(){ $(this).dialog("destroy").remove();}
> > > > > >     });}
>
> > > > > > /******** end of function: prettyPrompt ****************/
>
> > > > > > $("#btn1").click(function(){ prettyPrompt({message: "You are using
> > > > > > prettyPrompt"}); });
>
> > > > > > $("#btn2").click(function()
> > > > > > {
> > > > > >   prettyPrompt({
> > > > > >     title: "Your thoughts",
> > > > > >     message: "Do You like it?",
> > > > > >     cancelText: "No - It's Awful",
> > > > > >     onCancel: function(){ alert("Sorry to hear that"); },
> > > > > >     okayText: "Yes - It's Great",
> > > > > >     onOkay: function(){ alert("Glad to hear that"); }
> > > > > >   });
>
> > > > > > });
>
> > > > > > On Nov 13, 11:10 am, john6630 <[email protected]> wrote:
>
> > > > > > > I know this has been discussed/requested many times but I have not
> > > > > > > seen a solution posted. I love the look and simplicity of the 
> > > > > > > JQuery
> > > > > > > Modal Dialog documented 
> > > > > > > herehttp://plugins.jquery.com/project/modaldialog
> > > > > > > and I have seen many posts asking how to add Yes/No OK/Cancel 
> > > > > > > buttons.
> > > > > > > I have also seen the suggested code to add the buttons but do not 
> > > > > > > see
> > > > > > > how the response is passed back to the page etc. I am probably 
> > > > > > > being
> > > > > > > thick headed but can someone provide a sample site and code that
> > > > > > > provides this functionality. And if so, it would be great to add 
> > > > > > > it to
> > > > > > > the plug-in's demo page.
>
> > > > > > > What I need to do is very typical, I am sure. When user clicks on 
> > > > > > > a
> > > > > > > Delete button, I want to pop up a confirmation window and based 
> > > > > > > on Yes
> > > > > > > or No response perform the data deletion. The same as adding the
> > > > > > > following javascript
>
> > > > > > > btnDelete.Attributes.Add("onClick", "return confirm('Delete user
> > > > > > > now ...are you sure?','CONFIRM DELETE');")
>
> > > > > > > Any help greatly appreciated.
>
> > > > > > > TIA
> > > > > > > John

--

You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=.


Reply via email to