Last active
August 29, 2015 14:02
-
-
Save pier-oliviert/0242c65ada6dcd2e8bbd to your computer and use it in GitHub Desktop.
Shiny.js proof of concept
This file contains hidden or 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
| Everytime a HTML tag has the [as=*] attribute, Shiny will instantiate a Javascript object on the fly. It's not instantiate until it reaches the main Document. So you can manipulate it off screen and the object will only be created once it's appended to the document. | |
| No need to check for document ready or page:load(turbolinks), everything is instantiated as soon as a valid DOM is found. |
This file contains hidden or 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 Popup | |
| # el is <div class='popup'> | |
| constructor: (el) -> | |
| el.addEventListener 'click', @close | |
| close: (event) -> | |
| if event.target.classList.contains('close') | |
| event.currentTarget.remove() | |
| Shiny.Models.add Popup, 'MyProject.Popup' |
This file contains hidden or 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 Section | |
| # el is <section> | |
| constructor: (el) -> | |
| #set your listener here. You could add a listener here and block propagation to avoid the popup to close, etc. | |
| Shiny.Models.add Section, 'MyProject.Section' |
This file contains hidden or 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
| <!-- A popup --> | |
| <div class='popup' as="MyProject.Popup"> | |
| <section as='MyProject.Section'> | |
| <!-- Some stuff in here --> | |
| </section> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment