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

How do I prevent the form from refreshing on schemaFormRedraw #922

Open
GenyaB opened this issue Aug 24, 2017 · 2 comments
Open

How do I prevent the form from refreshing on schemaFormRedraw #922

GenyaB opened this issue Aug 24, 2017 · 2 comments

Comments

@GenyaB
Copy link

GenyaB commented Aug 24, 2017

I am using $scope.$broadcast('schemaFormRedraw'); after dynamically adding elements to my angular-schema-form, however, when I do this, it refreshes the form and reverts back to the first tab every time.

I've had a look at the render() and internalRender() functions inside the schema-form.js and have a feeling it's something in those two functions.

Here is how I am adding the elements:

//declaring the form and schema on enter

$scope.$on("$ionicView.enter", function(event, data) {
   $scope.schema = {
     type: "object",
     properties: {

     }
   };

    $scope.form = [
     "name",
     {
       type: "tabs",
       tabs: [
       ]
     }
   ];

 });

//adding tabs
$scope.tabAdd = function(tabName){
console.log($scope.form[1].tabs.length);
if($scope.form[1].tabs.length == 0){
 $scope.state = 0;
}
else{
 $scope.state = $scope.state +1;
}
console.log($scope.state);
var tab = {
     title: tabName,
     tabType: "top",
     items: []
   }

$scope.form[1].tabs.push(tab)

//this prevents the updateOn error that I get without it
$scope.$broadcast('schemaFormRedraw');
};

@json-schema-form/angular-schema-form-lead

@Anthropic
Copy link
Member

@GenyaB the schema and form are compiled into an Intermediate Representation which is then used for the display, updating the schema or form then regenerates the IR which causes the form to regenerate display. I have been wanting to find time to create a tab add-on that allows defining a schema/form to dsiplay as the content of the tab, but keep running out of time.

@GenyaB
Copy link
Author

GenyaB commented Sep 7, 2017

@Anthropic Ah I see, I've been playing around as well but no luck. Let me know if you come up with a working solution.

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