Skip to content Skip to sidebar Skip to footer

Curly Bracket Variable In Javascript

I have come across this a lot in ExtJS and I was wondering where it's coming from I have an example like this: view: new Ext.grid.GroupingView({ forceFit:true, gro

Solution 1:

That's a template. Somewhere in the rest of the code, the {text} in that string will be replaced with a value at run time.

Update:

Okay, look, you can do pretty much anything you want with it. I've don't have Ext.js handy so I can't give you straight-up code. but that argument is just an anonymous object. The new operation there creates an object, and uses that stuff as part of the contents. view will become the name of an attribute attached to SOMETHING -- to the window object if nothing else -- naming that new object.

If you want to know what's in it, console.dir in a debugger should dump out the contents. In those contents is almost certainly a string named groupTextTpl, and that's just a string, do with it as you will.

More probably, though, read up on template processing in Ext.js -- you can probably write code to use that template and make new, customized coipies from it.

Solution 2:

it's ah Object with two key-value pairs: 1. key: forceFit, value: true 2. key: groupTextTpl, value: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'second one is a string btw

Post a Comment for "Curly Bracket Variable In Javascript"