remove a dynamic model with javascript

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have some javascript that is basically performing a sql query by creating a dynamic model. When I'm done with the data, I'd like to remove the model from the page. Is there some way to delete or remove a model?

skuid.$M('MyModel').delete();
? or 
delete skuid.model.map().MyModel;
Photo of Matt Sones

Matt Sones, Champion

  • 31,600 Points 20k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,262 Points 20k badge 2x thumb
Cleanup is only necessary if you registered the Model with Skuid with model.register() --- the inverse of model.register() is model.unregister() . If you call model.unregister(), then the Model will only exist within the scope of your javaScript code. Skuid will no longer know about it and you'll not be able to access it via skuid.model.getModel(modelId) or other skuid.model API's.
Photo of Matt Sones

Matt Sones, Champion

  • 31,600 Points 20k badge 2x thumb
Nice.
So if I only need the model to perform a query and get data, I don't need to register it in the first place. Is that correct?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,262 Points 20k badge 2x thumb
Yes, I believe that is correct.