1

Once a page finishes loading, I use JQuery to change the href of every item based on some custom validation. So far so good but my problem is that opening the ECB will reset the href of that item. I have a function to change the links and would like to call it, after the ECB finished changing the hrefs to revert the changes the ECB did. Where would be such place?

Code to change the links:

    function changeLinks() {
        $(document).ready(function () {
            $("div.ms-vb.itx").each(function () {
                var itemid = $(this).attr("id");
                isValid = aktiverWF[itemid] == "0" || aktiverWF[itemid] == "1";
                if(!isValid)
                {
                    $(this).find("a").removeAttr("onclick");
                    $(this).find("a").unbind("click");
                    $(this).find("a").attr({ href: "javascript:alert('Gewählte Aktion ist nicht durchführbar, da ein Workflow aktiv ist.');" });
                }
            });
        });
    }
0

Finally found a way to keep the href as it was before the opening of the ECB. It happens in the CreateAjaxMenu(e) function. Code to keep the changes (with comment where changes were made) to the normal function from core.js:

    CreateAjaxMenu = function(e)
    {ULSrLq:;
        if (!IsContextSet())
            return;
        if (e==null)
            e=window.event;
        if (itemTable==null && ecbElm !=null)
            itemTable=ecbElm;
        var srcElement=e.srcElement ? e.srcElement : e.target;
        if (itemTable==null || (itemTable.tagName=="TABLE" && imageCell==null) ||
            (onKeyPress==false && !IsInCtxImg(srcElement) &&
             (srcElement.tagName=="A" ||
              srcElement.parentNode.tagName=="A")))
            return;
        var itab=itemTable;
        var p=itab.parentNode;
        if (p !=null && p.getAttribute('creatingAjax')==1)
            return;
        itab.parentNode.setAttribute('creatingAjax', '1');
        var ctx=currentCtx;
        var fn=function(ctx, tab)
        {ULSrLq:;
            itab.parentNode.replaceChild(tab, itab);
            tab.onclick=itab.onclick;
            tab.onmousehover=OnItem;
            tab.innerHTML = itab.innerHTML; // this line keeps the inner html and thus the old href
            OnItemDeferCall(tab);
            CreateMenuEx(ctx, tab, null);
            tab.parentNode.removeAttribute('creatingAjax');
        };
        FetchEcbInfo(ctx, itemTable.id, itemTable.tagName, fn);
        e.cancelBubble=true;
        return false;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.