-
14 Feb 2012 10:19 AM #1
Answered: SegmentedButton - button.text is 'undefined'
Answered: SegmentedButton - button.text is 'undefined'
I'm working through the SegmentedButton docs and I'm trying to add a listener for the buttons.
Problem is that it's text is undefined. Not sure why.
PHP Code:{ // BUTTON ROW
xtype: 'segmentedbutton',
layout: {
type: 'hbox',
pack: 'center',
align: 'middle'
},
allowMultiple: false,
config: {
baseCls: 'plain',
pressedCls: ''
},
items: [{
text: 'videos'
}, {
text : 'calendar'
}, {
text: 'sites'
}],
listeners: {
toggle: function(container, button, pressed){
console.log(button.text); // UNDEFINED
console.log("User toggled the '" + button.text + "' button: " + (pressed ? 'on' : 'off'));
}
}
}
-
Best Answer Posted by j.k
Okay, that is odd, can't reproduce that behavior. When printing out the button argument you should see something like this:
calling getText() on that object works as expected.Code:- _cls: Array[2]
- _iconAlign: "left"
- _itemId: "ext-button-7"
- _pressedDelay: 0
- _styleHtmlCls: "x-html"
- _text: "sites"
- config: Ext.Object.classify.objectClass
- [...redacted...]
- __proto__: TemplateClass
- $className: "Ext.Button"
- [...redacted...]
I'm using ST2 Beta2.
-
14 Feb 2012 10:31 AM #2
-
14 Feb 2012 10:33 AM #3
-
14 Feb 2012 10:35 AM #4
I haven't tested, but are you sure the button is passed as the second argument to your event handler function and not the first one? When in doubt do a
console.log(arguments)
and inspect the passed values
-
14 Feb 2012 10:39 AM #5
I'm actually logging as much as I can
I can see in the output of the 'button' the right value for '_text', but it's private and inaccessibleCode:console.log(container); console.log(button); console.log(pressed); console.log(button.text);
+ Ext.apply.create.Class
- _badgeCls: "x-badge"
- _baseCls: "x-button"
- _cls: Array[2]
- _hasBadgeCls: "x-hasbadge"
- _iconAlign: "left"
- _iconMaskCls: "x-icon-mask"
- _itemId: "ext-button-1"
- _labelCls: "x-button-label"
- _pressedCls: "x-button-rpc-pressed"
- _pressedDelay: 0
- _style: "margin-top: 5px;"
- _styleHtmlCls: "x-html"
- _text: "videos"
- _ui: "plain"
-
14 Feb 2012 10:55 AM #6
Okay, that is odd, can't reproduce that behavior. When printing out the button argument you should see something like this:
calling getText() on that object works as expected.Code:- _cls: Array[2]
- _iconAlign: "left"
- _itemId: "ext-button-7"
- _pressedDelay: 0
- _styleHtmlCls: "x-html"
- _text: "sites"
- config: Ext.Object.classify.objectClass
- [...redacted...]
- __proto__: TemplateClass
- $className: "Ext.Button"
- [...redacted...]
I'm using ST2 Beta2.
-
14 Feb 2012 4:36 PM #7
-
14 Feb 2012 6:45 PM #8


Reply With Quote
