Create property editor with multiple fields added dynamically
Hi,
I created my own plugin, small one, simple one which contains one input and two buttons: add & remove.
When press add button then new input will be insert below (also with add&remove button beside input)
When press remove button then input will be removed.
I have 2 problems:
When add new field, when I type text, also changes all inputs. I don't want to do that. Somehow inputs values are binding between them. How to fix this ? I want to type different text in different inputs.
When save and publish content, umbraco always save only first input, no matter how many inputs you created. Where is my mistake ?
As in your case the editing experience offers a list of inputs to edit the binding would need to behave similarly with each input binding to an index in an array type value
if in your controller your model value was set up like this
if (!$scope.model.value) {
$scope.model.value = [];
}
then the ng-model attribute on your input might look like this
Should also say as you are adding AND removing items it may be that instead of binding directly to something in model value you might be best binding to to the list property within your scope, then syncing the value of list to model value on save via...
$scope.$on("formSubmitting", function () {
$scope.model.value = $scope.list;
});
not in this simplified example your model value would end up exactly the same as $scope.list and contain an array of objects each with index,disabled and value properties if that is not what you want you would need to process your list before updating your model
Create property editor with multiple fields added dynamically
Hi,
I created my own plugin, small one, simple one which contains one
input
and two buttons: add & remove.When press add button then new input will be insert below (also with add&remove button beside input)
When press remove button then input will be removed.
I have 2 problems:
When add new field, when I type text, also changes all inputs. I don't want to do that. Somehow inputs values are binding between them. How to fix this ? I want to type different text in different inputs.
When save and publish content, umbraco always save only first input, no matter how many inputs you created. Where is my mistake ?
So my package.manifest
My html file:
My angularJS controller:
think your problem is this on your input
As in your case the editing experience offers a list of inputs to edit the binding would need to behave similarly with each input binding to an index in an array type value
if in your controller your model value was set up like this
then the ng-model attribute on your input might look like this
Should also say as you are adding AND removing items it may be that instead of binding directly to something in model value you might be best binding to to the list property within your scope, then syncing the value of list to model value on save via...
not in this simplified example your model value would end up exactly the same as $scope.list and contain an array of objects each with index,disabled and value properties if that is not what you want you would need to process your list before updating your model
Thanks for tips.
I used:
and
How about saving ? Still save first element from a list of inputs...
Hi Mihail ! Can you share your whole code. Or maybe your email Id??
Can you share whole code?/
is working on a reply...