2
votes

You often need View in View.

For example, a client that has many phone numbers. So you create a view for the client:

- app/view/client/Edit.js

and you create two views for the phone numbers:

- app/view/phone/Edit.js
- app/view/phone/List.js

What is the way to "tie" them properly? (I mean in the client Edit view, show Phones of this client (and only of this one)).

I've already gone through those examples, and I've made my custom MVC based on those "lessons" (that are far from being usable for making professionnal stuff):

You can test my example at my website here:

http://doonoo.com/intranet/gs.php

This is a full CRUD system (no CRUD example could be found with the MVC tutorials (and this is "kind of" important to me)).

But now I'd like to make another (model + store + view) about "phone", but when we edit the user, I want to display his/her own phone numbers, and (maybe) add / delete their phone numbers. This is kind of "opening a user view, which contains a phone view that is filtered with the user id".

Any idea / suggestion? What I've come so far is to create the "phones" view into the "edit user view" but I don't know how to apply the filter. I'm stuck.

Any idea welcome!!

Here's how it should work:

How it should work

1

1 Answers

1
votes

Your question is not very clear but let me take a stab -

Your edit user view is nothing but a form. This form, when presented to the user, has phone number related fields. (home, mobile, work, etc) If you want to be able to edit phone numbers from places other than edit user form, you are right, you need a "separate" view so that it can be reused. In this case, you can extend a fieldset (app/view/phone/Edit.js extends fieldset) and just add it to edit user form. This fieldset by itself wont be usable (it wont have any save logic) but it will be reusable across forms. When your edit user form is submitting, it will automatically submit phone fields too.