Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : CanJS and Ruby On Rails

$
0
0
I tried using modulejs but its still going to toolbar.js.coffee before discussions_app.js.coffee so it won't work as the html element still hasn't been printed to the DOM.

This is what I've got:

show.html.haml
  1. %script#app-template{type: "text/mustache"}
  2. .fill-container-wrap.discussions
  3. .well.discussion
  4. %h1 Discussions title
  5. %toolbar
  6. %script#toolbar-template{type: "text/mustache"}      
  7. %nav.navbar.navbar-default.navbar-discussion{role: "navigation"}
  8. .navbar-header
  9. %button.navbar-toggle{"data-target" => "#bs-example-navbar-collapse-1", "data-toggle" => "collapse", type: "button"}
  10. %span.sr-only
  11. Toggle navigation
  12. %span.icon-bar
  13. %span.icon-bar
  14. %span.icon-bar
  15. %ul.nav.navbar-nav
  16. %li.dropdown
  17. %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
  18. All Categories
  19. %b.caret
  20. %ul.dropdown-menu
  21. %li
  22. %a{href: "#"} Action
  23. %li
  24. %a{href: "#"} Another Action
  25. %li
  26. %a{href: "#"} something
  27. %li.divider
  28. %li
  29. %a{href: "#"} Seperated Link
  30.  
  31. #canjs

  32. :javascript
  33. console.log('hello 1');
  34. modulejs.require('canjs/apps/discussions/discussions_app');
  35. new DiscussionsApp('#canjs');
discussions_app.js.coffee
  1. modulejs.define "canjs/apps/discussions/discussions_app", ["canjs/apps/discussions/components/toolbar"], (Toolbar) ->
  2. console.log 'hello 2'
  3. can.Control.extend 'DiscussionsApp',
  4.       init: ->
  5.             @element.html can.view('app-template', {})
  6.                     return
toolbar.js.coffee
  1. modulejs.define "canjs/apps/discussions/components/toolbar", ->
  2.       console.log 'hello 3'

  3.       can.Component.extend
  4. tag: 'toolbar'
  5. template: can.view('toolbar-template', {})
  6. scope:
  7.       message: 'this is my toolbar'



and this is the output I'm getting from the console and you'll see that toolbar.js.coffee is showing before discussions_app.js.coffee

  1. Uncaught TypeError: Object #<DocumentFragment> has no method 'replace' can.jquery.js?body=1:3430



I'm not sure what else to do really :S

Viewing all articles
Browse latest Browse all 3491

Trending Articles