Is editor.unregister() a safe function to use?

  • 1
  • Question
  • Updated 3 years ago
In previous questions, I've struggled with performance of pages that use addRow() as there is no addRows() method like there is for updateRow()/updateRows()

In looking into alternatives, I've found solutions that work, but they do not seem consistent, and I'm wondering if they are safe to use. unregister() in particular. I'll try and focus on the latest release (7.20).

So I have a model that is shown in a table, and whose rows are created in Javascript. addRow() is slow as it causes updates - so what if we remove the UI elements tied to a model before we add the rows, then attaching it back? This works - sample code below. The "NewModel" is linked to a table on the page - this is retrieved in the uiEditor variable.

var params              = arguments[0],
    $                   = skuid.$,
    uiEditor            = $('#mytable').data('object').editor,
    newModel            = skuid.model.getModel("NewModel"),
    count               = 0,
    numberOfRecords     = 100;


for(; count < numberOfRecords ; count++){
    var newRecord = newModel.createRow({
        editModeForNewItems : true,
        additionalConditions: [
           {field: 'Name' , value: "Anything"}
        doAppend: true

uiEditor.lists[0].render({"doNotCache" : true});

I've tried replacing that last line with uiEditor.register(newModel), but the rows won't show in the table. I think that's because registering a model against a UI Editor means that the UI will only update after that registration.

Including uiEditor.register(newModel) doesn't seem to have any side effects, and as it feels and reads more logical (unregister, do stuff, then register, then call render), I'm tempted to leave it in - but I wanted to check first to make sure I've not stumbled across something that may be changed and break in future, particularly as unregister() is not documented and therefore possibly unsafe.

A part of my suspicion is that I've been exploring this on an older version - 6.8.7 (yes, I know, but Theme Builder appears to have broken my themes so I can't update just yet). In that version, unregister didn't work on its own, and I had to loop over the model's registeredEditors and unregister them one by one, and using registerModel causes models to become registered multiple times - which seems to be asking for trouble. Were these areas tweaked since 6.8.7?
Photo of Gary


  • 1,538 Points 1k badge 2x thumb

Posted 3 years ago

  • 1

Be the first to post a reply!