开发者

SharePoint 2007 onchange event not unbinding in ie6

Im confident that this isnt a sharepoint 2007 issue, but id rather cover all of my bases.

I am consulting at a large company, developing a sharepoint solution for their intranet. One of my tasks is to switch the regular dropdownlist in the sharepoint 2007 listview with something that has type ahead and filtering. So i chose a jquery combobox.

Now, in everything but ie6 this combobox works, and the onchange event also works. My process is this:

function diidFilterLinkTitleNoMenuOnChange()
{
     FilterField("{9232EB4D-2E5D-40D3-A1C0-818CC21AC839}","LinkTitleNoMenu",this._selOption.value, this.selectedIndex);
}

$(document).ready(function(){
window.dhx_globa开发者_Python百科lImgPath='../_layouts/Intranet.Portal.Custom/PeopleChangesFiles/imgs/';
    var y = document.getElementById('diidFilterLinkTitleNoMenu');
    if(y != null)
    {
          $('#diidFilterLinkTitleNoMenu').change(function(){}).attr('onchange',function(){});


          var z = dhtmlXComboFromSelect('diidFilterLinkTitleNoMenu');
          z.enableFilteringMode(true);
          z.attachEvent("onchange",diidFilterLinkTitleNoMenuOnChange);
          y.parentNode.removeChild(y);       

    }        

    })

I am removing the current onchange event before turning the select list into a combobox, then reassigning a different onchange event.

What is happening as far as i can tell in ie6, is that the old onchange event is still there, still attached, and firing first as it breaks the code and my event doesnt run.

Is there a special way in removing events in ie6? Or am i doing this wrong?


Thats because change() method is a shortcut for .bind('change', handler). And .bind attaches event handler not removes or overrides.

Quote from bind() page:

When an event reaches an element, all handlers bound to that event type for the element are fired. If there are multiple handlers registered, they will always execute in the order in which they were bound.

Use unbind to remove event handlers: $('#diidFilterLinkTitleNoMenu').unbind('change');

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜