Skip to content

Commit a5b7a3c

Browse files
committed
fixed the issue where data-context is ruining pageviews, and trying to change duplicateCachedPage to the way it should be. refresh should now be a data-refresh boolean value in the <a> tag. also now beginning to work on a hash value for data-context, taking in three key-value pairs - url, panel, and refresh
1 parent b6c5854 commit a5b7a3c

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

experiments/splitview/jquery.mobile.splitview.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535

3636
$(document).unbind(".linkhandler");
37-
$(document).bind( "click", function(event, isRefresh) {
37+
$(document).bind( "click", function(event) {
3838
var link = findClosestLink(event.target);
3939
if (!link){
4040
return;
@@ -79,6 +79,7 @@
7979
//if data-ajax attr is set to false, use the default behavior of a link
8080
hasAjaxDisabled = $link.is(":jqmData(ajax='false')"),
8181

82+
isRefresh=$link.jqmData('refresh'),
8283
$targetPanel=$link.jqmData('panel'),
8384
$targetContainer=$('div:jqmData(id="'+$targetPanel+'")'),
8485
$targetPanelActivePage=$targetContainer.children('div.'+$.mobile.activePageClass),
@@ -103,7 +104,9 @@
103104
return;
104105
}
105106

106-
$activeClickedLink = $link.closest( ".ui-btn" );
107+
//still need this hack apparently:
108+
$('.ui-btn.'+$.mobile.activeBtnClass).removeClass($.mobile.activeBtnClass);
109+
$activeClickedLink = $link.closest( ".ui-btn" ).addClass($.mobile.activeBtnClass);
107110

108111
if( isExternal || hasAjaxDisabled || hasTarget || !$.mobile.ajaxEnabled ||
109112
// TODO: deprecated - remove at 1.0
@@ -398,8 +401,15 @@
398401
panelContextSelector = $this.parents('div[data-role="panel"]').jqmData('context'),
399402
pageContextSelector = $this.jqmData('context'),
400403
contextSelector= pageContextSelector ? pageContextSelector : panelContextSelector;
401-
if(contextSelector && $this.find(contextSelector).length){
402-
$this.find(contextSelector).trigger('click', true);
404+
//if you pass a hash into data-context, you need to specify panel, url and a boolean value for refresh
405+
if $.type(contextSelector) === 'object' {
406+
var $targetContainer=$(':jqmData(id="'+contextSelector.panel'")'),
407+
$targetPanelActivePage==$targetContainer.children('div.'+$.mobile.activePageClass),
408+
isRefresh = contextSelector.refresh === undefined ? false : contextSelector.refresh;
409+
$.mobile.changePage([$targetPanelActivePage, contextSelector.url],'fade', reverse, false, undefined, $targetContainer, isRefresh);
410+
}
411+
else if(contextSelector && $this.find(contextSelector).length){
412+
$this.find(contextSelector).trigger('click');
403413
}
404414
});
405415

js/jquery.mobile.navigation.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@
561561
//if to exists in DOM, save a reference to it in duplicateCachedPage for removal after page change
562562
//unless method is post - which in REST case it has a url that is the same as a URL that lists all of a resource
563563
//but upon creation of a new record, you want to point to that particular record after the fact.
564-
if( to.length && type != 'post'){
564+
if( to.length ){
565565
duplicateCachedPage = to;
566566
}
567567

@@ -590,7 +590,9 @@
590590
// correct url. loading into a temprorary element makes these requests immediately
591591
if(pageElemRegex.test(html) && RegExp.$1 && dataUrlRegex.test(RegExp.$1) && RegExp.$1) {
592592
redirectLoc = RegExp.$1;
593-
593+
if(redirectLoc != url) {
594+
duplicateCachedPage=null;
595+
}
594596
}
595597

596598
if( redirectLoc ){

0 commit comments

Comments
 (0)