-
1 Dec 2011 11:20 AM #1
Controller not finding ID
Controller not finding ID
I have a controller which is looking for a component by ID. According to the docs I should
be able to create a control
however this only works when i put the 'viewport' word before the item id...Code:this.control({ '#mycontainer': { itemtap: function() { blah blah blah } } });
Is this an omission in the docs for Ext.ComponentQuery or am I doing somethingCode:this.control({ 'viewport #mycontainer': { itemtap: function() { blah blah blah } } });
incorrectly ? (more than likely).
Thank you!
Kevin
-
1 Dec 2011 11:33 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Everything you do should be thought of reuse and using the id property goes against this.
- Technically it should work as it should be looking for the itemId or id.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Dec 2011 11:39 AM #3
I agree with the reuse philosophy. However this is a panel that will be created once and never destroyed. I figured I didn't need to define something for a single panel.
Having said that, it doesn't change the result i'm getting in the controller and the fact that it is not working as documented ;-)
PS - dataview docs do not have 'itemtap' as an event.
Thanks,
Kev
-
1 Dec 2011 3:59 PM #4
itemtap documentation has been added for the next release.
Can you provide a simple testcase for this? I've not came across it before.Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
2 Dec 2011 4:04 PM #5
Thank you for taking a look at this. Please bear in mind that this is a VERY stripped down version of the barest of code to replicate the problem I am having (from a 600+ line app - phew). At the end you'll see the control references - one commented out, one not.
KevinCode:new Ext.application({ name: 'MyApp', views: [ 'Main' ], controllers: [ 'Profiles' ], launch: function() { this.getMainView().create().setActiveItem(1); } }); Ext.define('MyApp.view.Main', { extend: 'Ext.Panel', config: { fullscreen: true, layout: 'card', items: [{ itemId: 'profilegridview', xtype: 'dataview', store: 'Profiles', itemTpl: '<div style="display: block; border: solid 1px #000000; width: 75px; height: 75px; float: left; margin: 2px; ">{ID}</div>' }] } }); Ext.define("MyApp.model.Profile", { extend: 'Ext.data.Model', fields: [ { name: 'ID' }, { name: 'USERSIDFK' } ] }); Ext.define('MyApp.store.Profiles', { extend: 'Ext.data.Store', model: 'MyApp.model.Profile', data: [ {"ID":"2206226","USERSIDFK":"2129649" }, {"ID":"504242","USERSIDFK":"494131" }, {"ID":"226650","USERSIDFK":"224686" } ] }); Ext.define('MyApp.controller.Profiles', { extend: 'Ext.app.Controller', stores: [ 'Profiles' ], init: function() { this.control({ '#profilegridview' : { // DOESN'T WORK // 'viewport #profilegridview' : { // WORKS itemtap: function() { alert('select'); } } }); } });
-
3 Dec 2011 3:10 PM #6
Okay, Thanks. I'll open a bug. Something weird going on here.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
24 Jan 2012 2:49 PM #7Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
I can't reproduce this in PR4 - can you upgrade your app and try it out?
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
25 Jan 2012 3:01 PM #8
Hi Ed,
Nope - still have to use the 'viewport #id' to get it to work.
Kev
Code:config: { refs: { 'profileviews': '#profileviews', 'profilelist': 'profilelist', 'gridview': '#profilegridview', 'listview': '#profilelistview', 'photoStrip': '#photoStrip', 'profileDetailCard': '#profileDetail', 'photoGallery': '#photoGallery', 'photoCarousel': 'photocarousel', 'profileNavBar': '#profileNavBar' }, control: { 'profilelist button[action=switchView]': { tap: 'switchView' }, 'viewport #profilegridview' : { itemtap: 'loadProfile' }, 'profiledetail button[action=backToProfiles]': { tap: 'backToProfile' }, 'profiledetail button[action=backToProfileDetail]': { tap: 'showProfile' }, 'viewport #photoStrip' : { itemtap: 'showCarousel' } } },
-
26 Jan 2012 5:30 PM #9Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Oh but hang on you're using itemId instead of id - that's not going to work. itemId is a locally-scoped identifier so it will work once you've got hold of a parent container (like Viewport). If you don't have a parent container in the selector it will never find the itemId because itemId is not guaranteed to be globally unique.
The upshot is - if you want to be able to address this view with a global id, use id instead of itemId.Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote