Skip to content

Instantly share code, notes, and snippets.

@benjiwheeler
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjiwheeler/9020428 to your computer and use it in GitHub Desktop.
Save benjiwheeler/9020428 to your computer and use it in GitHub Desktop.
Backbone rails correction
class Punchline.Views.MemesIndex extends Backbone.View
renderA: ->
$(@el).html("rendered A")
$(@el).html()
renderB: ->
$(@el).html("rendered B")
@el
# this is the way it is in Railscast
renderC: ->
$(@el).html("rendered C")
this
class Punchline.Routers.Memes extends Backbone.Router
routes:
'': "index"
index: ->
alert 'index here!'
view = new Punchline.Views.MemesIndex()
alert view.renderA()
alert $(view.renderB()).html()
alert $(view.renderC().el).html()
$('#container').html($(view.renderC().el).html())
# incorrect way it was in http://railscasts.com/episodes/323-backbone-on-rails-part-1
# $('#container').html(view.render().el)
show: (id) ->
#alert "showing id #{id}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment