We’re seeing this with the new update: INVALID_PAR...
# suitecommerce
k
We’re seeing this with the new update: INVALID_PARAM Invoking the method “addChildViews” with an incorrect parameter: (Home.View). It will still work but it will be deprecated in the future. Please check the documentation. The only parameters used are those in the documentation - childViewIndex and childViewConstructor. We do have multiple child views being added here….has something changed in the api?
s
This warning is returned as the part of the changes to introduce extension safe mode
Without seeing your exact code, I can't tell you exactly what's wrong, but it is generally because you are referencing a core module in your child view that is not allowed
k
ok - will check that out and report back…
we’re using Backbone.View.extend({
thats the only thing I can find…
s
Yeah don't do use that anymore
Use SCView
There are docs that explain safe mode but you may be interested in what I wrote about it https://developers.suitecommerce.com/build-sustainable-and-stable-extensions.html#avoid-using-core-modules-in-customizations
k
yes - referencing this now….its a bit of work to convert
checking out your github files
s
The new tutorial I wrote covers all of the new modules. General advice is that your module's custom properties should live in the customised constructor function; everything outside should only relate to the SCView base module's properties
k
thanks for your help
netsuite halo 1
When migrating our code from Backbone.View.extend to using the SCView as in your examples on git, can we use something like ExampleUserPreferencesDetailsView.prototype.initialize or create other functions? Or are we limited to just prototype.getContext?
s
Basically, anything outside of your constructor object should be an existing property of SCView. Anything custom should be in your constructor function
When it comes to
initialize()
specifically, I don't think you need this as you can just put everything you would normally put into that function into the constructor
k
ok - will be giving this a whirl
Just wondering why getContext is not within the constructor
because its an existing property….? are there others not in your git example?
actually in the docs I see
Copy code
validateContextDataRequest
and
Copy code
contextDataRequest
s
getContext is defined on the base class, so you define outside of the constructor on the prototype
contextDataRequest is for adding a view to a parent view that has a particular kind of model, like when you're adding a child view to a facet cell view and want to access the item's model
(I found out yesterday that this is not well known so I might have to write something up about it)
k
ok - all good info
When adding events or a new function to the child view, would you add to the constructor this.events = { event code} or this.newFunction = function() etc?
s
if you're adding an arbitrary property to the child view, then you define it in the constructor
k
this is a brand new child view, not adding to an existing
s
... I'm not sure how that affects what I've said?
k
newView.prototype.getEvents = function ()
s
Right
k
got it
s
1. Constructor function 2. Set the view prototype 3. Restore the constructor 4. Override any 'built in' prototype methods 5. Return the constructor
k
just getting used to which methods are available to SCVIEW
s
Yah. They're all in the API docs but you can also lookup the class in the core code if you want
👍 1
k
but the function that the events call is in the constructor
s
That's fine
I use
getEvents
here. I bind the delete button click to a
removeUserPreference
callback I define in the constructor
k
exactly what I did - awesome
netsuite halo 1
this.on(‘afterViewRender’, function() { _.defer(function() { self.newView(); }); });
having some trouble with that
s
Yah someone else reported that too. I am not sure if
afterViewRender
is available
My thought at this point is to override the prototype's
render
function so that it calls the parent view's class render AND THEN does your code
k
ok - will go there
would that be “legal”
s
Good question! Yes, I think so. Unlike other methods, it is protected not private.
I have had success with something like this:
Copy code
ExampleView.prototype.render = function () {
    SCView.prototype.render.call(this);
    
    // my code
}
A dev confirmed that my code sample above is valid, so feel free to use that
"It should be the same but a difference would be that now, that code will be executed after the children views are rendered, when in the old view, it was triggered before render the children"
k
ok - i had to put it down for a little - will report back
ok - got pretty far - newView.prototype.render = function () { SCView.prototype.render.call(this); this.newFunction(); }
the last problem is that if you navigate away from the page and then come back it doesnt load
actually, the defer within the protype.render() solved this so I think im good