Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yep. There are 3 paths I know about:</p> <ol> <li><p>Create fixtures manually like you are doing now. This can feel like duplicate code. The pros are that it's pretty simple (and intuitive as lots of people start out that way). Longer term I think it's good if it helps you reduce the coupling between your markup and your jQuery scripts. I found that using this technique encouraged me to figure out the simplest markup required for my jQuery code.</p></li> <li><p><strong>This is probably the answer you're looking for.</strong> Generated fixtures from your <code>haml</code> templates. <a href="http://pivotallabs.com/javascriptspecs-bind-reality/" rel="nofollow noreferrer">This blog post</a> will walk you through one method, but the google can show you some more. This is nice because you're guaranteed that the haml code and JS is in sync. The down-side is that it's some complexity that can-- and does-- go wrong.</p></li> <li><p>All my recent projects have gone further and eliminated all but a very basic dependence on the generated markup. My templates generally output a single <code>&lt;div&gt;</code> along with some data attributes on the page, and the Javascript builds all the DOM elements for me (instead of haml). <a href="https://github.com/jquery/jquery-tmpl" rel="nofollow noreferrer">Javascript based templates</a> facilitate this. The Jasmine tests are quite simple, and the testing can usually be done sans fixtures, using var <code>$dom = $('&lt;div&gt;');</code> as the whole fixture. If you are going to have to deal with the data on the client anyways, this, I find, is overall simpler.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload