views:

317

answers:

1

Short Explanation:

I have a script control that has the click event being handled in the script file. The Click handler pops up a confirm prompt and returns the prompt's value.

Problem:

IE sees the return False (Cancel is selected on the confirm box) and there is no postback. Firefox ignores this and fires the postback.

Solution?:

I read that if I were doing this the old fashion way, I would need to have:

onClick="return SomeMethod();"

In the markup. There hopefully is a way to do this with script controls?

Example:

Here's what I have in the script file:

//THIS IS THE METHOD CLICK CALLS
handleLnkDeleteButtonClick: function(e)
{
    var confirmed = confirm('This will delete the current Message category and move all messages to the Oprhan cataegory.  Continue?');
    return confirmed;
},

initialize: function()
{
    this._lnkDeleteButton = $get(this._lnkDeleteButtonID);
    this._lnkDeleteButton.idpicker = this;

    //HOOK BEGINS HERE
    this._lnkDeleteButtonClick = Function.createDelegate(this, this.handleLnkDeleteButtonClick);
    $addHandler(this._lnkDeleteButton, "click", this._lnkDeleteButtonClick);
    //END HOOK HERE

    NDI.WebControls.Client.PersonalMessageTypePicker.callBaseMethod(this, 'initialize');
},

dispose: function()
{
    $removeHandler(this._lnkDeleteButton, "click", this._lnkDeleteButtonClick);
    NDI.WebControls.Client.PersonalMessageTypePicker.callBaseMethod(this, 'dispose');
}
A: 

Ok so solved it myself after about way too much time trying to phrase things correctly for google. Turns out there is a method to call so that you don't have to worry about returning true or false.

handleLnkDeleteButtonClick: function(e)
{
    var confirmed = confirm('This will delete the currery Message category and move all messages to the Oprhan cataegory.  Allow?');
    if (!confirmed)
    {
        e.preventDefault();
    }
},

So instead of returning confirmed, I merely had to check it's value and call the e.preventDefault method to stop the click from firing.

Programmin Tool