Slide 1

Slide 1 text

Ember integrating into existing sites

Slide 2

Slide 2 text

James Croft @james_croft matchingnotes.com

Slide 3

Slide 3 text

MINIFIED I work at

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Progressive enhancement JS web apps

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

The content needs to be indexable

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Computed properties Run loop Bindings Observers

Slide 18

Slide 18 text

1 {{track-player track=controllers.track}} 1 App.TrackPlayerComponent = Ember.Component.extend 2 setupPlayer: ( -> 3 player = new YT.Player @get('element') 4 @set('player', player) 5 ).on('didInsertElement') 6 7 playVideo: ( -> 8 @get('player').loadVideoById @get('track.videoId') 9 ).observes('track.videoId') 10 11 App.TrackController = Ember.ObjectController.extend()

Slide 19

Slide 19 text

1 App.ApplicationRoute = Ember.Route.extend 2 actions: 3 playTrack: (track) -> 4 @controllerFor('track').set('content', track) 5 1
    2 {{#each track in controllers.tracks}} 3
  • 4 5 {{track.title}} 6
  • 7 {{/each}} 8

Slide 20

Slide 20 text

1
  • 2 3 Andhim - Reeves 4
  • Slide 21

    Slide 21 text

    1 $('body').on 'click', 'a.play', (e) -> 2 $link = $(this) 3 artist = $link.data('artist') 4 title = $link.data('title') 5 videoId = # Search YouTube for the video 6 7 track = Ember.Object.create 8 artist: artist 9 title: title 10 videoId: videoId 11 12 # Get the track into the application 1
  • 2 3 Andhim - Reeves 4
  • Slide 22

    Slide 22 text

    1 $('body').on 'click', 'a.play', (e) -> 2 $link = $(this) 3 artist = $link.data('artist') 4 title = $link.data('title') 5 videoId = # Search YouTube for the video 6 7 track = Ember.Object.create 8 artist: artist 9 title: title 10 videoId: videoId 11 12 trackController = App.__container__.lookup('controller:track') 13 trackController.set('content', track) 1
  • 2 3 Andhim - Reeves 4
  • Slide 23

    Slide 23 text

    __container__

    Slide 24

    Slide 24 text

    No content

    Slide 25

    Slide 25 text

    1 2 3 4 5 6 $('body').on 'click', 'a.play', (e) -> 7 $link = $(this) 8 artist = $link.data('artist') 9 title = $link.data('title') 10 videoId = # Search YouTube for the video 11 12 track = Ember.Object.create 13 artist: artist 14 title: title 15 videoId: videoId 16 17

    Slide 26

    Slide 26 text

    1 App.initializer 2 name: "setup-play-link-handler", 3 initialize: (container, application) -> 4 trackController = container.lookup('controller:track') 5 6 $('body').on 'click', 'a.play', (e) -> 7 $link = $(this) 8 artist = $link.data('artist') 9 title = $link.data('title') 10 videoId = # Search YouTube for the video 11 12 track = Ember.Object.create 13 artist: artist 14 title: title 15 videoId: videoId 16 17 trackController.set('content', track)

    Slide 27

    Slide 27 text

    No content

    Slide 28

    Slide 28 text

    No content

    Slide 29

    Slide 29 text

    pjax

    Slide 30

    Slide 30 text

    TURBOLINKS? um, did you just say?

    Slide 31

    Slide 31 text

    No content

    Slide 32

    Slide 32 text

    No content

    Slide 33

    Slide 33 text

    No content

    Slide 34

    Slide 34 text

    No content

    Slide 35

    Slide 35 text

    1 view = App.SimilarTracksView.create 2 controller: App.SimilarTracksController.create() 3 4 5 view.appendTo('.similar-tracks')

    Slide 36

    Slide 36 text

    No content

    Slide 37

    Slide 37 text

    1 view = App.SimilarTracksView.create 2 controller: App.SimilarTracksController.create() 3 container: App.__container__ 4 5 view.appendTo('.similar-tracks')

    Slide 38

    Slide 38 text

    _________container_________

    Slide 39

    Slide 39 text

    1 view = App.__container__.lookup('view:recommended-list') 2 view.set('controller', App.SimilarTracksController.create()) 3 4 view.replaceIn('.similar-tracks')

    Slide 40

    Slide 40 text

    •Server rendered HTML •Enhanced using Ember •pjax so that the Ember app is long lived

    Slide 41

    Slide 41 text

    •Ember, not just for single page apps •Just use the bits that you need

    Slide 42

    Slide 42 text

    Questions?

    Slide 43

    Slide 43 text

    James Croft @james_croft matchingnotes.com