Announcement

Collapse
No announcement yet.

clsJQuery.jqButton with confirmation dialog. How???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • clsJQuery.jqButton with confirmation dialog. How???

    I am trying to have a confirmation dialog when pressing a delete button.
    The documentation shows clsJQuery.jqButton.functionToCallOnClick and clsJQuery.jqButton.includeClickFunction. I get the button to show a confirm dialog, but I haven't a clue how I can use the result to abort posting. It seems like it posts the same data no matter what.

    Has anyone solved this? Or is there another way? The plan is to do this for multiple buttons in a table (not just one single button on a page).

  • #2
    My setup so far:
    Adding a script to the page
    Code:
            
    "<script type='text/javascript'>
    function userConfirm(name)
    {
    var answer=confirm('hey - are you sure?? All the devices for '+name+' will be deleted! ');
    if(answer)
    {return  true;}
    else
    {return false;}
    }
    </script>");
    In the plugin
    Code:
    deleteButton.functionToCallOnClick = "userConfirm('" + item.Name + "'); ";
    deleteButton.includeClickFunction = true;
    I can see that the page source adds my userConfirm to the top of the click function for the button, and it is shown, but it is having no impact to the execution of the post. It posts no matter what.

    Code:
    $(function() {
    $('#deleteButton_9bdf6d5f-7b72-4c38-a498-152ddcb8c659_ID598385').button({icons: {primary:'',secondary:''} });
    $('#deleteButton_9bdf6d5f-7b72-4c38-a498-152ddcb8c659_ID598385').click(function(e) {
    userConfirm('abcde'); //<-- My function inserted
    var theform =$('#'+$(this)[0].form.id);
    var theData = theform.serialize();
    returnTrue = false;
    theData = theData+'&id='+this.id+'&deleteButton_9bdf6d5f-7b72-4c38-a498-152ddcb8c659=Submit';
    commonAjaxPost(theData,'AutomowerConnectSeer_General_Config');
    if(returnTrue) {
    location.reload();
     return false;
    }
    else {
     return false;
    }
    });
    });

    Comment


    • #3
      I made my own type of button by "borrowing" from the original button

      https://gist.github.com/oesolberg/0f...ba325da649cc3d

      Now in PostBackProcess I check if the return is Submit or Cancel.
      Not optimal, but a quick and dirty solution. Feel free to use it.

      Edit: I think revision 7 is getting to the point that others can use it

      Comment

      Working...
      X