I have to load multiple I18N-properties that have the same sharing content into an array. I've tried
arrayIDs = oBundle.getText().includes(".id.");
It said that it can't read the property 'includes' of undefined. Most likely because there isn't anything in getText(). But this has to be variable. This method is made for one property, is there something where I can get multiple properties?
edit: nvm I solved it... If you have the same problem: I discovered
oBundle.aPropertyFiles[0].getKeys();
for myself and this gets all the keys of the I18N properties you need. After that you can make oBundle.getText(key) to get the according text and implement your own filtering logic.
Related
I have a .stp file that has random integer name values for model names in the Model Browser but a valid (ie. human readable) Component Name. I would like to replace the default name with the Component Name in the Model Browser for these cases.
I've looked at a couple similar posts on SO but nothing has worked for me as yet (here and here). I'm using version 6.3.1 of the viewer.
In my investigation into where the data is stored, I've found a strings array in the InstanceTree as well as a PropDbLoader (in the ViewerPropertyPanel). The strings array seems to get populated with the name data (in an interesting ASCII array look-up setup) and the PropDbLoader has properties for the models. The name for the model in the Model Browser popup looks to come from within the ModelStructureTreeDelegate class (InstanceTree.getNodeName). I'd like to be able to extend or override the getNodeName and populate it with Component Name but I have (as of yet) not found a way to get at this data in the model tree.
Any insight or direction would be greatly appreciated
Basically you will need to extend/override the default DIV creation behaviour for model tree nodes here and customize to your needs:
ModelStructureTreeDelegate.prototype.createTreeNode
See here for code sample.
Here is an example of what I'm trying to do with Sencha Ext JS 6.5.2 Modern:
https://fiddle.sencha.com/#view/editor&fiddle/2b2i
I am trying to use an ArrayStore to load some values into the combobox. When I click on the drop down arrow, or search, I get an error stating that:
Cannot read property 'getFilters' of null
The problems seems that it is not loading the data correctly, and 'me.getStore()' returns null.
Am I not using the 'store' properly?
After some digging into the API and trying to find numerous examples across the web, I believe I figured it out.
I was setting the 'store' key as a string. slap head, instead of a config object. I changed that from:store: 'states' to store: { type: 'states' }
I also had the wrong field specified in the model: displayAS vs displayAs.
once I did this, everything worked as expected.
Please check the docs to find that ExtJS stores have no alias config. You may want to change your store identification from alias to storeId.
Also, check the store config of the combobox to find that ExtJS takes "either a Store instance, configuration object or store ID", but does not instantiate a new store by alias.
So you have to instantiate a new states store instance before your combobox is rendered. For the instantiation of stores of which only one instance should exist throughout the app, I can recommend adding them to the stores config of the Application.
I'm trying to customize an example of Mike Bostock's Hierarchical Edge Bundling:
So far I've been able to generate what think is an equivalent json file with my data but I haven't been able to make it show.
In the console I get the following error:
TypeError: n is undefined
and the following warning:
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
I have tried in different browsers running a local server to no avail.
I also found these questions which didn't solve the problem.
You can find my code and altered json in this gist.
Any help will be greatly appreciated.
I've been trying to debug this error all morning, and finally figured it out.
Sample:
https://gist.github.com/mbostock/1044242
When it looks through the json array, every single imports must have a valid entry. In the example, if you delete the any line of that JSON array you will get the "TypeError: n is undefined"
The only way I found it was by copying the JSON file, and then replacing all the name properties with blank spaces. This eventually allowed me to find the one import that did not exist because I had an error in formatting.
Hope this helps.
I am using a library, Instafeed, which creates a feed object. The feed object is pretty complex.
I need to convert this object to a string value for transfer.
Problem is, I'm getting the Uncaught TypeError: Converting circular structure to JSON. All of the answer I've come across say to alter the object to get rid of the circular reference. However, the object is pretty complex and I'd rather not have to do that.
Is there any other way to serialize this object that would avoid the circular reference error?
EDIT
Actually, I'm looking at the object in the console and I see this:
I expanded the context key 30 times in total and it just kept going. I'm not having memory issues, and the feed does run fine as intended with the loading of the images as the only delay, so it doesn't seem like this library creating an infinite loop of nested elements.
Is this just a peculiarity of how the object gets displayed and not indicative of the structure of the object itself?
And how do I serialize something like this?
ALSO, I tried a JSON-to-XML plugin but on conversion with that I got the following error:
Uncaught RangeError: Maximum call stack size exceeded
Examining https://github.com/stevenschobert/instafeed.js/blob/master/src/instafeed.coffee, it looks as though the context property will sometimes, but not always, be a circular reference. The one thing context is guaranteed NOT to be is null.
Test for the circular reference while serializing, and if found, serialize it as null. Deserialize on the other side by re-circularizing it.
(This is an answer only to the specific case, not the general - this object has the good grace to be IMMEDIATELY circular. A multi-step circle would be rather more complicated)
JSON is a data format, not a means of saving arbitrary JavaScript objects. So trying to push a JS object which is more than just data over the network via JSON sounds fraught. You might consider whether your design could move just the information that you actually need to move.
That said, it does look like at least one person has tried to solve the circular reference problem in library form.
If you're specifically looking for alternatives, you should check out the Circular JSON package.
Replace your calls to JSON with CircularJSON:
function MyCircularClass() {
this.circular = this;
}
var obj = new MyCircularClass();
var objSerialized = CircularJSON(obj);
console.log(obj);
// ouputs '{ "ciruclar": "~" }'
Here's your silver-bullet: cycle.js. If you're using npm it's available as a package too.
You can use it to de-cycle the object so that it can be serialized with:
var stringForm = JSON.stringify(cycle.decycle(myObject));
Later if you're loading the object back into javascript you can make it cycled again with:
cycle.retrocycle(JSON.parse(stringForm));
I've encountered a weird situation, I've been using the extend library and the _.extend command from underscore, in the following way:
var extended = extend({}, objA, objB);
I get only properties from one of the objects in the result, is there anything about extend that might be preventing it from getting all the properties from both objects?
I've used this pattern everywhere and it seemed to work as expected so far. Both are plain objects, not arrays or functions.
EDIT: I tried to make a demo, but it seems to work with both jQuery and Underscore - http://jsfiddle.net/x4UHQ/2/
While making the demo (from the objects I printed in my logs), I noticed one that when printed in console.log didn't appear as a string - it's a mongoose type of ObjectId, maybe that's somehow causing the problem? (that specific field exists in the output object, so I don't know)
UPDATE: this was the solution - UnderscoreJS wont extend object (add a lean option to the mongoose query - because that's somehow makes the object incompatible with underscore.
Sorry for new response, it better fits as comments for Madd0g response (but i don't have required reputation points for it).
You are right, it is fault of mongoose object, {lean: true} is one option to fix it, other options is calling mongooseObj.field.toJSON() - in some case it is more convenient method. For example if you have user object in controller (from auth middleware), and you need to transform some fields, then you don't need to refetch model from db.
So the problem was that one of the objects was an object from the mongoose library, it made extend commands break, the fix was to get the db object from mongoose with the lean option.
something like personModel.find({fname: "Joe"}, null, { lean: true })