Last active
August 29, 2015 13:56
-
-
Save benjiwheeler/9020428 to your computer and use it in GitHub Desktop.
Backbone rails correction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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