Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Update form from modal popup #10

Closed
danielo515 opened this issue Jun 5, 2015 · 1 comment
Closed

[question] Update form from modal popup #10

danielo515 opened this issue Jun 5, 2015 · 1 comment

Comments

@danielo515
Copy link

Hello,

Sorry for not labeling this as question, but I can not add labels.

I am having a very bad experience trying to update a text field from a modal popup. The layout is a bit complex, and I am getting a bit lost tracking how children sees the data object. I'll try to specify the layout:

Form

  • Some property
  • Array whit children
  • Single child (columns)
    • Modal popup

So there are three levels of nested manifest: the main one, the manifest for each column and then another manifest for the modal popup. The modal popup has a button, which bind function perform some stupid calculations, and then stores the result in the data object. The problem is that when the modal closes, the data updated is not reflected on the column (parent). I based the modal in your example of the main website(copy and paste, same _updateMe function), but in it there is no update from any function, just good old object --> fields binding. I don't know if it matters, but I am passing just the whole data object to the modal child manifest.

Also it will be nice if you have time to explain me how the data object is passed to children. It looks like magic for me when I only have to use "text" (for example) as identifier inside a repeated section, and it is magically bind to the correct item inside the list.

Thank you very much.

@ermouth
Copy link
Owner

ermouth commented Jun 5, 2015

In general, modal is a promise. It is:

  • resolved when modal closes normally (some control inside triggers event "commit")
  • rejected when modal is escaped (closed by X button, or Esc, or triggering event "cancel" from inside, or you clicked screen dimmer if any).

Root form does not catch modal close, you must let root know explicitly that it must redraw. It‘s intentional behavior. So in your case, when your modal mutates data object of parent form directly it can be something like this:

$ctrl.modal({
  /*modal params here*/
}).then(function(modalData){
  // Here goes code for normal close
  $ctrl.my().root.my("redraw");
}).fail(function(){
  // Here goes code for escaped close
  $ctrl.my().root.my("redraw");
});

If you provided modal with cloned data (that is more suitable in most cases), you must apply data, received from the modal, to a caller form – and then redraw entire caller.

I only have to use "text" (for example) as identifier inside a repeated section, and it is magically bind to the correct item

Did not understand a question. Show the code excerpt, please.

@ermouth ermouth closed this as completed Jul 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants