jupiterjs / jquerymx

jQuery MVC Extensions. jQuery extensions that makes all the annoying stuff easier.
http://javascriptmvc.com
553 stars 374 forks source link

3.2 beta: nested view seems not to work #76

Closed wclr closed 13 years ago

wclr commented 13 years ago

Well, it seems that nested views do not render.

I've got my main view:

<% $.each(this, function(i, item){ %> <% view(commonViewsPath + "items/item.ejs", item) %> <% }) %>

and nestd view item.ejs:

  • this.attr
  • It worked with JVMC 3.1 But now i've got notghing inside my main view (though item.ejs is download from server and definitely render is called - I've debuged it in jquery\view\ejs\ejs.js)

    if I replace this call of the nested view with inline HTML:

    <% $.each(this, function(i, item){ %>

  • item.attr
  • <% }) %>

    I've got what it should be.

    daffl commented 13 years ago

    I am fairly sure you need to output the returned view e.g.:

    <% $.each(this, function(i, item){ %>
        <%= view(commonViewsPath + "items/item.ejs", item) %>
    <% }) %>

    Or even better:

    <% $.each(this, function(i, item){ %>
        <%= $.View(commonViewsPath + "items/item.ejs", item) %>
    <% }) %>

    I am surprised that

    <li>this.attr</li>

    Worked though, I would expect it to be

    <li><%= attr %></li>
    wclr commented 13 years ago

    Well but then there is another issue.

    You are right about

  • <%= attr %>
  • Yes now If I use "<%=" instead of "<%" i've got the rendering result BUT as a result i've got raw HTML (text with tags) on the screen.

    and in 3.1 it workd without "<%=" but with "<%" and i believe view in EJS files acts as a shortcut for $.View.

    daffl commented 13 years ago

    Yes it pretty much is a shortcut for $.View which just returns the view and doesn't render it. If you want to render unescaped use "<%==".

    wclr commented 13 years ago

    ok, thank you, David =)