Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class window.HomeView extends Backbone.View
template: _.template($('#home').html())
render: (eventName) ->
$(@el).html(@template())
return @
class window.Page1View extends Backbone.View
template: _.template($('#page1').html())
render: (eventName) ->
$(@el).html(@template())
return @
class window.Page2View extends Backbone.View
template: _.template($('#page2').html())
render: (eventName) ->
$(@el).html(@template())
return @
class window.AppRouter extends Backbone.Router
routes:
"":"home",
"page1":"page1",
"page2":"page2"
initialize: ->
_.bindAll @
$('.back').on 'click', (event) ->
window.history.back()
false
@firstPage = true
return
home: ->
console.log '#home'
@changePage new HomeView
page1: ->
console.log '#page1'
@changePage new Page1View
page2: ->
console.log '#page2'
@changePage new Page2View
changePage: (page) ->
$(page.el).attr('data-role', 'page')
page.render()
$('body').append($(page.el))
transition = $.mobile.defaultPageTransition
#We don't want to slide the first page
if @firstPage
transition = 'none'
@firstPage = false
$.mobile.changePage $(page.el), {changeHash: false, transition: transition }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.