问题
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