NYCPHP Meetup

NYPHP.org

[nycphp-talk] JSON and MVC

Christopher Hendry chendry at gmail.com
Fri Jul 17 10:06:39 EDT 2009


As Anirudh and Snyder (and pretty much everyone else) has said, it comes
down to either innerHTML and blocks of server-side rendered HTML or js
templating.

I'm curious though about javascript's introspection abilities, might it be
possible for an element to look into itself (or clone its children) and
render from there?

Working from Snyder's example (and thanks Chris, I didn't know about
MochiKit) can we expand to include the data elements in the original
template?


> <div id="Messages" type="parent_set">
>  <div id="messageid" class="message" type="child_element">
>    <h3 data_element="subject">Message Subject</h3>
>    <p>Posted by <span data_element="author">Author</span> on <span
> data_element="date">Date</a></p>
>    <div class="content" data_element="content">
>      Lorem ipsum dolor sit amet...
>    </div>
>  </div>
>  ...
> </div>
>
>
Then all of the javascript/function/templating (appendMessageFromData) which
you'd need to create for each active element - rewriting yet another view
for your templates - gets abstracted into one method (which it's too early
for me to write).  My point is, we already have the view, the first time the
page is rendered.  I guess this is the XSLT/JSLT approach that Anirudh
mentioned, but I still get sick to my stomach when I hear XSLT. Though I
haven't used it, the thought of JSLT makes me shiver...

I don't get why you'd want to do everything on the server? Offloading
> it to the client is a little harder to get right, but it scales like
> crazy once you do.
>
>
Overall, I still use innerHTML for the most part, unless I'm doing something
that is strictly key=>values (like select elements) mostly because I'm still
concerned about the client's parsing abilities.  Sure, _we_ all have sleek
computers and fast browsers, but most people don't.  So, yes, offloading to
the client makes sense (until the next browser comes along and screws things
up), but as we approach Web 3.0 I'm concerned about
request/response/parse/render overhead for the average user - sure it
scales, until the next version on windows comes out.

The real question is - why is it that I live in the middle of the Catskills
and it's nearly impossible to find decent firewood?

- Chris

-- 

"When you do things right, people won't be sure you've done anything at
all."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090717/0eaf932b/attachment.html>


More information about the talk mailing list