jQuery mobile routing solution?

六眼飞鱼酱① 提交于 2019-12-25 04:24:41

问题


I have a mobile app which was build with jquery mobile in a classic way - on every page transition html content is loaded via AJAX request and inserted into data-role="content" element.

What I want to refactor is client-side, there's an ugly code that finds specifc id in DOM in order to differentiate pages and run url dependant code.

...

if $page.find('#commentary').length
   unless @CommentaryView
       @CommentaryView = new CommentaryView
   @CommentaryView.render page
   return

if $page.find('#coupons').length
   unless @CouponsView
       @CouponsView = new CouponsView
   @CouponsView.render page
   return

...

Could you advice me some jquery-mobile routing solution? Or is it fine to keep find element by id routing? Thanks!

来源:https://stackoverflow.com/questions/28551932/jquery-mobile-routing-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!