sencha touch 扩展路由器
我无法让 Ext.Router 注册对 URL 的更改。我使用 sencha touch 站点上的模型视图控制器示例开始了我的应用程序。
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'startup.png',
icon: 'icon.png',
onReady: function() {
KOI.views.viewport = new KOI.views.Viewport();
}
});
我有一个路由文件(在应用程序之前加载)
Ext.Router.draw(function(map) {
map.connect("main", { controller: 'menu', action: 'index' });
});
这是控制器
KOI.controllers.menus = new Ext.Controller({
index: function(options) {
KOI.views.viewport.setActiveItem(KOI.views.mainMenu);
}
});
Ext.regController('menu', KOI.controllers.menus);
,但将 URL 更改为 http://myapp.com尽管控制器可以工作,但 /#main 不执行任何操作。我缺少什么想法吗?任何帮助将不胜感激。 Ext.router 的文档不多,我看不到调试正在发生的事情的好方法。
I am having trouble getting Ext.Router to register changes to the URL. I started my application with the example for model view controller on sencha touch site.
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'startup.png',
icon: 'icon.png',
onReady: function() {
KOI.views.viewport = new KOI.views.Viewport();
}
});
And I have a routes file, (loaded before app)
Ext.Router.draw(function(map) {
map.connect("main", { controller: 'menu', action: 'index' });
});
This is the controller
KOI.controllers.menus = new Ext.Controller({
index: function(options) {
KOI.views.viewport.setActiveItem(KOI.views.mainMenu);
}
});
Ext.regController('menu', KOI.controllers.menus);
but changing the URL to http://myapp.com/#main does nothing, although the controller does work. Any ideas what I am missing? Any help would be greatly appreciated. There isnt very much documentation for Ext.router and I cant see a good way to debug whats going on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ext.setup
相当于Ext.onReady
,除了在 dom 加载并可访问时调用回调函数之外不执行任何其他操作。然而,
Ext.regApplication
会创建一个新的Ext.Application
,并将您的配置对象传递给它。Ext.Application
的一部分是Ext.Application.onBeforeLaunch
和Ext.Application.launch
。onBeforeLaunch
设置历史记录支持(如果您已启用),然后调用launch
。如果
launch
不返回 false,则onBeforeLaunch
将继续使用您的最后一个历史记录项/令牌、您的调用
或者如果所有其他方法都失败Ext.redirect
>defaultUrl{controller: 'application', action: 'index'}
Ext.setup
is equivalent toExt.onReady
and does nothing else but call a callback function when the dom is loaded and accessible.Ext.regApplication
however creates a newExt.Application
, passing in your config object to it.Part of an
Ext.Application
is theExt.Application.onBeforeLaunch
andExt.Application.launch
.onBeforeLaunch
sets up history support if you have that enabled, and then callslaunch
.If
launch
doesn't return false thenonBeforeLaunch
will go ahead and callExt.redirect
with either your last history item / token, yourdefaultUrl
or if all else fails{controller: 'application', action: 'index'}