intel / appframework

The definitive HTML5 mobile javascript framework
http://app-framework-software.intel.com/
MIT License
2.43k stars 882 forks source link

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

Open pragmaware opened 8 years ago

pragmaware commented 8 years ago

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.

EvsanDlg commented 8 years ago

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().