The search function could use a little love. You want to pass nodes into
the view constructor, rather than hard-code selectors all over the place.
This lets you unit test your code without a real DOM.

Think in terms of separating DOM access, network IO, and your
transformation logic on the returned JSON. This is the start of splitting
out concerns. If you try to figure out how you could test different parts
without the network (encapsulate IO in an object, swap out a mock) or the
DOM (a DOM node abstraction), you'll start to naturally break the code into
pieces that are MVCish.

Hope this helps a little

Jared

On Nov 9, 2011 6:17 PM, "Andrew Dodson" <andrew.j.dod...@gmail.com> wrote:

Hello, any one know much about MVC patterns in JavaScript? + have 5 minutes
to read a little code?

*demo*: http://mrswitch.github.com/pic-n-flick/

There is only one file doing the work.

*script*: https://github.com/MrSwitch/pic-n-flick/blob/master/js/script.js


I haven't had much experience with MVC structure and this is my first kick
about with Backbone.js.
I had a lot of problems with it. And was totally stumped trying to manage
two Views or even two collections+models firing the correct triggers on the
right Views... it all got a bit messy there. I hence shelved the first
attempt at
https://github.com/MrSwitch/pic-n-flick/blob/master/js/script_kaput.js

I also couldn't bind an event to the *window* object via backbone's
delegateEvents<http://documentcloud.github.com/backbone/#View-delegateEvents>,
without hacking it separatly.

Any insight into the sobering world of MVC or backbone would be fantastic.

A

-- 
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here:
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to