appframework icon indicating copy to clipboard operation
appframework copied to clipboard

Passing no anchor to $.afui.loadContent() wants to switch views

Open pragmaware opened this issue 9 years ago • 1 comments

When no anchor is passed to loadContent() it creates a "floating" anchor not attached to a view. loadDiv() then thinks it has to switch view and breaks.

pragmaware avatar Apr 03 '16 02:04 pragmaware

I think, that the main problem is in anchor-hack in function loadContent(): af.ui.js line 903: anchor = anchor || document.createElement("a"); Thus anchor never false and 'currentView' var in loadDiv() function always belongs to it and never to target div view:

line 733: //check current view
            var currentView;
            if(anchor){
                currentView=this.findViewTarget(anchor);
            }
            else
                currentView=this.findViewTarget(this.activeDiv);

And because the anchor is "floating" - currentView var is [] and never equals to target view and so passes the check:

759: if(!isSplitViewParent&&(newView||currentView&&currentView.get(0)!==view.get(0))){
                //Need to transition the view
                newView=currentView||newView;
                ....

and as result tries to make a transition to this [] view.

I see the easiest fix: in loadContent() move the anchor-hint line right above this.loadAjax(..) call, not before hash checking, because it is not needed for loadDiv().

EvsanDlg avatar Jun 10 '16 09:06 EvsanDlg