-
3 Oct 2012 11:07 PM #1
Answered: Can't create a segmentedbutton
Answered: Can't create a segmentedbutton
Hi,
I am trying to create an 'Ext.SegmentedButton' and cannot manage to do so.
It feels like the class is not recognized by the Framework.
1. Trying to instantiate using 'xtype', I am getting this error: 'Uncaught ReferenceError: segmentedbutton is not defined'
2. Trying to instantiate with 'new Ext.SegmentedButton' from the example from the Sencha Touch documentation, I am getting this error: 'Uncaught TypeError: undefined is not a function'.
Please advice
-
Best Answer Posted by hadukiCode:
//new Ext.SegmentedButton({}) Ext.create('Ext.SegmentedButton',{})
-
4 Oct 2012 1:37 PM #2
Can you show more of your code please? It is hard to help when there is very little to work with.
-
7 Oct 2012 8:03 AM #3
You are right, I did not supply enough details... Sorry for that.
I receive this error on Google Chrome, with sencha-touch-2.0.1.1
Here is the code for the view ReportPost.js :
And the app.js code:Code:Ext.define('Surfspace.view.ReportPost', { extend: 'Ext.form.Panel', requires: ['Ext.SegmentedButton'], segmentedButton: new Ext.SegmentedButton({ allowMultiple: true, items: [ { text: 'Option 1' }, { text: 'Option 2', pressed: true }, { text: 'Option 3' } ], listeners: { toggle: function(container, button, pressed){ console.log("User toggled the '" + button.text + "' button: " + (pressed ? 'on' : 'off')); } } }), config: { items: [{ xtype: 'button', itemId: 'mapButton', ui: 'round', text: 'Choose spot', }], } });
Please advice.Code:Ext.application({ name: 'Surfspace', requires: ['Ext.Button'], views: ['ReportPost'], launch: function() { Ext.fly('appLoadingIndicator').destroy(); Ext.Viewport.add(Ext.create('Surfspace.view.ReportPost')); } });
-
7 Oct 2012 9:11 AM #4
I don't see anything syntactically wrong with your code. I even made a little demo of it and nothing came up.
-
7 Oct 2012 10:04 AM #5
Well, this is weird. I see this error on both Chrome and Safari.
Here is a link to the website, you can see it yourself:
https://surf-space.com/tests/segmentedbutton/
On Chrome I get:
Uncaught TypeError: undefined is not a function
And on Safari I get:
TypeError: 'undefined' is not a constructor (evaluating 'new Ext.SegmentedButton')
Any idea what may cause this?
-
7 Oct 2012 11:39 AM #6
Make sure it is actually including the source for Ext.SegmentedButton. I looked at all the JS files being called and I don't see it being loaded.
-
7 Oct 2012 7:51 PM #7
Code://new Ext.SegmentedButton({}) Ext.create('Ext.SegmentedButton',{})I write English by translator.
-
8 Oct 2012 10:32 PM #8
@haduki , your suggested change to
was successful.Code:Ext.create('Ext.SegmentedButton',{})
The code I originally used was copy-pasted from the Sencha Touch 2 documentation. I have added a comment about that, and hopefully they will change it.
Thank you.
-
9 Oct 2012 4:43 AM #9


Reply With Quote