0

Using JQuery Dialog http://jqueryui.com/dialog/#modal-confirmation The dialog box appears whenever the page loads I only want it to appear when 'Remove Invoice' is clicked.

i've tried:<input id="RemoveInvoice" type="button" value="Remove Invoice" onclick="ConfirmDeleteInvoice()" />

then putting the actual JS inside a ConfirmDeleteInvoice function:

  function ConfirmDeleteInvoice() {
      //  $(function () { //removed this line and added the above line
        $("#dialog-confirm").dialog({
            resizable: false,
            height: 140,
            modal: true,
            buttons: {
                "Are you sure you want to delete this invoice": function () {
                    $(this).dialog("close");
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
    });
    }

ERROR: JavaScript runtime error: 'ConfirmDeleteInvoice' is undefined

Sorry still a beginner at JS so please bear with. Thanks

3
  • where are you putting your javascript in? head? Commented Mar 27, 2013 at 15:32
  • try: $('#RemoveInvoice').on('click', function(){}); and put everything from ConfirmDeleteInvoice inside that anonymous function and remove the onclick from the element. Commented Mar 27, 2013 at 15:33
  • you could just put ConfirmDeleteInvoice() function inside of a click handler.. btw i dont know if you pasted the code in but your it has some extra brackets Commented Mar 27, 2013 at 15:35

1 Answer 1

2

You've got an extra trailing }); right before your last closing brace, take that out and it'll work.

Also, in my fiddle you'll see I've added the click event in jQuery, as onclick inside HTML is considered bad practice. I did this by adding:

$("#RemoveInvoice").click(ConfirmDeleteInvoice);

See here: http://jsfiddle.net/P4VHw/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.