Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Backbone.js Backbonejs-后退按钮不';如果页面转换在同一页面上,则无法工作_Backbone.js_Routing_Event Handling_Transition - Fatal编程技术网

Backbone.js Backbonejs-后退按钮不';如果页面转换在同一页面上,则无法工作

Backbone.js Backbonejs-后退按钮不';如果页面转换在同一页面上,则无法工作,backbone.js,routing,event-handling,transition,Backbone.js,Routing,Event Handling,Transition,简要介绍我的程序,最后是问题: 我有两页。第一页按行列出产品,并附有简短说明。如果您单击其中一个,您将在详细信息页面上着陆 详细信息页面列出了产品的详细信息,下面是一些相关的产品。如果您单击其中一个相关产品,将使用从REST界面获取的新信息再次呈现相同的页面 如果我想使用浏览器后退按钮或自己的后退按钮进入上一个产品详细信息页面,将显示一个空白页面。这只发生在我的iPad上。在桌面浏览器上使用Chrome很好。我调试了应用程序,发现backbonejs路由永远不会被调用。我不知道为什么 以下是我的

简要介绍我的程序,最后是问题:

我有两页。第一页按行列出产品,并附有简短说明。如果您单击其中一个,您将在详细信息页面上着陆

详细信息页面列出了产品的详细信息,下面是一些相关的产品。如果您单击其中一个相关产品,将使用从REST界面获取的新信息再次呈现相同的页面

如果我想使用浏览器后退按钮或自己的后退按钮进入上一个产品详细信息页面,将显示一个空白页面。这只发生在我的iPad上。在桌面浏览器上使用Chrome很好。我调试了应用程序,发现backbonejs路由永远不会被调用。我不知道为什么

以下是我的详细信息页面代码:

define([ 
    "jquery", 
    "lib/backbone",
    "lib/text!/de/productDetails.html"
], 
function( 
    $, 
    Backbone, 
    ContentTemplate
){
var PageView = Backbone.View.extend({

        // product details template
        template: _.template(ContentTemplate),

        // back-button clicked
        events:{
            'click a#ac-back-button':'backInHistory',
        },

        // init
        initialize: function(options){

               this.options=options;

               // bind functions
               _.bindAll(this, 
                  'render',
                  'renderRelatedSeriePlainproduct',
                  'backInHistory'
            );

        // listen for collection
        this.listenTo(this.options.relatedCollectionPlainproduct, 'reset',this.renderRelatedSeriePlainproduct);
        },

        // back button
        backInHistory: function(e){

               e.preventDefault();

               window.history.back();
        },

        // render template 
        render: function(){

           // render template
               this.$el.html(this.template(this.model.models[0].attributes));
           return this;
        },

        // render related products
        renderRelatedSeriePlainproduct: function (){

               var models = this.options.relatedCollectionPlainproduct.models;

               if(models.length==0){
                  $('.ac-plainproduct').hide();
               } else{

              var elem = $('#ac-related-listing-plainproduct');

                  var ct="";
                  ct+='<ul id="ac-list-related-plainproduct">';
                  $.each(models, function(key, value){
                     ct+='<li>';
                     ct+='<a href="index.html?article_id='+value.get('article_id')+'&type='+value.get('type')+'&serie='+value.get('series')+'#product-detail">Link';
                    ct+='</a>';
                    ct+='</li>';
                });
                ct+='</ul>';

                elem.append(ct);
            }
        }


    });

    // Returns the View class
    return PageView;
});

我尝试使用allowSamePageTransition,但没有成功。也许有人能给我一个暗示。谢谢

看来jQuery Mobile和主干网的路由器有冲突。请看这里:


这不是原因。我禁用了jquery mobile的路由

// Prevents all anchor click handling
$.mobile.linkBindingEnabled = false;

// Disabling this will prevent jQuery Mobile from handling hash changes
$.mobile.hashListeningEnabled = false;
// Prevents all anchor click handling
$.mobile.linkBindingEnabled = false;

// Disabling this will prevent jQuery Mobile from handling hash changes
$.mobile.hashListeningEnabled = false;