문제

짧은 설명 :

스크립트 파일에 클릭 이벤트가 처리되는 스크립트 컨트롤이 있습니다. 클릭 핸들러는 확인 프롬프트가 나타나고 프롬프트의 값을 반환합니다.

문제:

즉, 반환 거짓 (확인란에서 취소가 선택됨)을보고 포스트 백이 없습니다. Firefox는 이것을 무시하고 포스트 백을 발사합니다.

해결책?:

나는 이것을 구식 방식으로하고 있다면 다음을해야한다는 것을 읽었다.

onClick="return SomeMethod();"

마크 업에서. 스크립트 컨트롤로 이것을 할 수있는 방법이 있기를 바랍니다.

예시:

스크립트 파일에있는 내용은 다음과 같습니다.

//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');
}
도움이 되었습니까?

해결책

좋아, 너무 많은 시간을 거친 후에는 Google을 위해 일을 정확하게 표현하려고 노력했습니다. True 또는 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();
    }
},

따라서 확인을 반환하는 대신, 나는 단지 그 가치를 확인하고 e.preventDefault 메소드를 호출하여 클릭이 해고를 중지해야했습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top