使用jQueryMobileRequireJS和主干不在WindowsPhone7Lumia上显示
因此,我有一个非常简单的两页应用程序,使用requirejs主干 结构非常简单 在索引页上调用require 包含的库的列表 然后在jqm路由关闭后调用路由器页面 jqmconfig使用jQueryMobileRequireJS和主干不在WindowsPhone7Lumia上显示,jquery,windows-phone-7,jquery-mobile,backbone.js,requirejs,Jquery,Windows Phone 7,Jquery Mobile,Backbone.js,Requirejs,因此,我有一个非常简单的两页应用程序,使用requirejs主干 结构非常简单 在索引页上调用require 包含的库的列表 然后在jqm路由关闭后调用路由器页面 jqmconfig define(['jquery'], function($){ $(document).bind("mobileinit", function () { $.mobile.ajaxEnabled = false; $.mobile.linkBindingEnabled = false; $
define(['jquery'], function($){
$(document).bind("mobileinit", function () {
$.mobile.ajaxEnabled = false;
$.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
// Remove page from DOM when it's being replaced
$('div[data-role="page"]').live('pagehide', function (event, ui) {
$(event.currentTarget).remove();
});
});
});
路由器页面
define(['jquery', 'underscore', 'backbone','views/home/home',
'models/products/productCollection',
'views/products/productTypes',
'jqm'],
function($, _, Backbone,HomeView,ProductsType,ProductListView ) {
var AppRouter = Backbone.Router.extend({
//define routes and mapping route to the function
routes: {
'': 'showHome', //home view
'home': 'showHome', //home view as well
'products/productTypes' : 'showProductTypes',
'products/productList/:ID' : 'showProductList',
'products/productList/:ID/' : 'showProduct',
'maps/search' : 'showMapSearch',
'*actions': 'defaultAction'
},
initialize:function () {
// Handle back button throughout the application
$('.back').live('click', function(event) {
window.history.back();
return false;
});
this.firstPage = true;
//this.products = new Products();
},
cachedProductTypes: null,
productType : {}, //this is not adding
products : {}, //this is not adding
getProducts:
function(callback)
{
if (this.cachedProductTypes !== null) {
return callback(this.cachedProductTypes);
}
var self = this;
$.getJSON('data/product.json',
function(data)
{
self.cachedProductTypes = data;
callback(data);
}
);
},
parseResponse : function(data) {
result = { prodTypes: [], products: [] };
var type;
var types = data.data.productTypeList;
var product;
var i = types.length;
var tmpItem;
$(types).each(function(index, element) {
});
$.each(types, function(i,item){
//create book for each item and then insert into the collection
tmpItem={
productID:i,
id:item.id,
name:item.name,
longName:item.longName,
ordering:item.ordering
};
result.prodTypes.push(tmpItem);
});
this.productType = result.prodTypes;
this.products = result.products;
},
defaultAction: function(actions){
this.showHome();
},
showHome:function(actions){
// will render home view and navigate to homeView
var homeView=new HomeView();
homeView.render();
this.changePage(homeView, 'fade');
},
showProductTypes:function(){
var self = this;
//show spinner
this.getProducts(
function(data)
{
self.parseResponse(data);
var productTypesArray = self.productType;
var productList=new ProductsType(productTypesArray);
console.log(productTypesArray);
var productListView=new ProductListView({collection:productList});
productListView.bind('renderCompleted:ProductsType',self.changePage,self);
productListView.update();
}
);
},
showMapSearch:function(){
var self = this;
//run your code
},
changePage:function (view, transition) {
//add the attribute 'data-role="page" ' for each view's div
console.log("pagechanged");
if (transition != "slidefade") {
transition = "pop";
}
view.$el.attr('data-role', 'page');
$('.ui-page').attr('data-role', 'page');
//append to dom
$('body').append(view.$el);
if(!this.init){
$.mobile.changePage($(view.el), {changeHash:false, transition: transition});
}else{
this.init = false;
}
}
});
$(document).ready(function () {
console.log('App Loaded');
app = new AppRouter();
Backbone.history.start();
});
return AppRouter;
});
这在除了windows phone之外的所有设备上都能很好地工作——我需要让它工作
当前仅显示一个白色屏幕,请参见此处
这个页面似乎也不起作用——所以我刚刚做了一个基本页面,它只调用了一个require js脚本,这个脚本刚刚加载到jQuery中,有一个文档就绪的call alerts hello,它甚至会转到一个白色页面在windows phone上查看此url。。疯子我在这里添加了一个更小更基本的版本。。你能解决这个问题吗?我面临着类似的问题,无法让它工作