当我添加jquery mobile 1.3.2时,为什么我有一个额外的空页?

时间:2013-12-01 16:04:36

标签: jquery-mobile backbone.js

当我加载jquery mobile时,我有一个额外的空页面,当我在html中使用options标签时,它会与应用程序混淆(更改为白页)。

但只有当我有data-native-menu="false"

这是额外页面:

<div data-role="page" data-url="/" tabindex="0" class="ui-page ui-body-c" style="min-height: 629px;">

有人可以向我解释如何在没有额外页面的情况下使用jquery mobile吗?

代码:

主:

require(['app', 'jquery', 'backbone', './router'], function (App, $, Backbone, Router) {
    'use strict';

    $( document ).on( "mobileinit",
        // Set up the "mobileinit" handler before requiring jQuery Mobile's module
        function() {
            // Prevents all anchor click handling including the addition of active button state and alternate link bluring.
            $.mobile.linkBindingEnabled = false;

            // Disabling this will prevent jQuery Mobile from handling hash changes
            $.mobile.hashListeningEnabled = false;
            // $.mobile.selectmenu.prototype.options.nativeMenu = false;
            $.mobile.ajaxEnabled = false;
            $.mobile.pushStateEnabled = false;
            $('div[data-role="page"]').live('pagehide', function (event, ui) {
                $(event.currentTarget).remove();
            });
        }
    )

    require( ['jquery-mobile-bower'], function() {
        // Instantiates a new Backbone.js Mobile Router
        var router = new Router();
            Backbone.history.start();
    });
});

路由器:

define([ "jquery", "backbone", './views/views'], function($, Backbone, views) {

    var changeView = function(view){
        view.render([{}]);
        $(view.el).attr('data-role', 'page');
        $('body').append(view.el)
        var el = view.el;
        $.mobile.changePage($(view.el));
    }

    // Extends Backbone.Router
    var CategoryRouter = Backbone.Router.extend( {

        // The Router constructor
        initialize: function() {
            // Tells Backbone to start watching for hashchange events
            $('.back').live('click', function(event) {
                window.history.back();
                return false;
            });

        },

        // Backbone.js Routes
        routes: {
            "": "index",
            "aa": "aa"
        },

        // Home method
        index: function(){
            var view = new views.Index();
            changeView(view);
            view.on('changePage', function(pageName){

            })
        },


        aa: function(){
            var view = new views.A();
            changeView(view);
        }

    } );

    // Returns the Router class
    return CategoryRouter;

} );

由于

0 个答案:

没有答案