Guest User

Untitled

a guest
Jan 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. class views.SlideShowView extends Backbone.View
  2. el: '.deck-container'
  3.  
  4. constructor: (opts) ->
  5. super
  6.  
  7. jade = require('jade')
  8. template = jade.compile $("#deck_template").html()
  9. @deckHTML = template()
  10.  
  11. # Editor asks to update slides from parent window. This code is run in a iframe.
  12. $(window).bind "message", (e) =>
  13. data = e.originalEvent.data
  14. # Set html contents of the slideshow is set to a backbone model
  15. @model.set JSON.parse data
  16.  
  17. # Render slides again always when we get a change.
  18. # Backbone automatically detects changes in models
  19. @model.bind "change", =>
  20. @render()
  21.  
  22. render: ->
  23.  
  24. # @el is body element
  25. $(@el).html @deckHTML
  26. $(@el).prepend @model.getHtml()
  27. $.deck(".slide")
Add Comment
Please, Sign In to add comment