{{{
The 4th episode discusses partial updates of widgets.
* Using the @event@ instance to transport payload data between widgets.
* Updating the page by sending back arbitrary JavaScript and markup from trigger states.
* Extracting partials to separate widget views.
* Using @#render@ in both views and states for DRY code.
BTW, please feel free to send me feedback or requests for future episodes – I appreciate!
}}}
Hey, great stuff as usual, thanks Nick. I figured out this technique last week, so it was good to see you create a screencast about it.
I think the escape_js is very important, that tripped me up. I dealt with it by calling Rails’ html_safe helper. But I think the Apotomo way is better.
The power of the multiple renders in Apotomo is fantastic and reminds me just how much Rails will benefit from a major ActionView refactor.
One more thing: it really does depend on the application. Since this is more work than just rendering the entire view, it makes the most sense when the entire view takes significantly to render and/or transfer from the server compared to a single row in a table. In my case, each row calls a costly SQL statement that gets the minimum value of a column. So it’s nice to get a faster response.
Also, in another example, if the user is initiating AJAX calls with multiple items in the same widget, you can arrange to affect one item at a time and not mucked with the others until they are ready to be rendered. Nice!
This is working toward maybe using mustache and backbone and using Apotomo to render JSON. Yow!
LikeLike
Nick, the YouTube videos don’t appear correctly (tried looking directly on YouTube, too)
LikeLike
I’m a bit nervous about the very last part of the screencast, where you’re putting JS+HTML code into a model for the update(). I’d much rather see an approach where JS functions is written and put into the display for the widget (here, some sort of JS function like updateTaskList() ) and then the update event in the controller does render text on a call to that,, or variations on that theme.
Also, given the importance of escape_js, why not make it part of every render?
Finally, another suggestion, unrelated to this example: if you are gonna do more screencasts (and I hope you do!), perhaps some sort of list of topics that we can see upcoming? There’s some more stuff I’d ask about but I don’t know if you’re about to cover it or if no one has ever suggested it. 🙂
LikeLike
@John: Can you post an example about your idea to the cells-and-apotomo mailing list?
The upcoming topics is a good idea – maybe we can use the screencast page for that. Thanks!
LikeLike