-
9 Dec 2011 3:02 AM #1
Dynamic Carousel : Adding item erroring
Dynamic Carousel : Adding item erroring
Here is the portion code.
response = pattuStore.load({scope:this,callback: function(records, operation, success){var currentPattu = 0;pattuCarousel=Ext.ComponentMgr.get("pattuCarousel");while (currentPattu < (records.length)) {pattuCarousel.add({html:'<div>'+ records[currentPattu].data.pattuText + '</div>'});pattuCarousel.setIndicator(currentPattu);currentPattu++;}}});
Error is as follows:
Uncaught TypeError: Cannot call method 'createChild' of null.
The error was in
addIndicator: function() {
this.indicators.push(this.element.createChild({
sencha-touch-all-debug-w-comments.js:53516 Uncaught TypeError: Cannot call method 'createChild' of null
tag: 'span'
}));
},
-
9 Dec 2011 5:50 AM #2
Hi.
Can you please format your code inside "code" tags?
However, I think you misunderstood the use of the "setIndicator" function:
It accepts a boolean value which tells the carousel if display or not the carousel indicator.
Hope this helps.Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
9 Dec 2011 6:00 AM #3
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
9 Dec 2011 6:05 AM #4
Attaching the code below. BTW -- the error occurs pattuCarousel.add({html ... itself -- so it does not reach setIndicator
Code:response = pattuStore.load({ scope:this,callback: function(records, operation, success) { var currentPattu = 0; pattuCarousel=Ext.ComponentMgr.get("pattuCarousel"); while (currentPattu < (records.length)) { //var element = new Ext.Panel({}); //element.setHtml(records[currentPattu].data.pattuText); //pattuCarousel.add(element); pattuCarousel.add({html:'<div>'+records[currentPattu].data.pattuText+'</div>'})pattuCarousel.setIndicator(currentPattu);//pattucarousel.indicator.indicators[currentPattu].dom.onclick=tapIndicator;currentPattu++; } }});
-
9 Dec 2011 6:09 AM #5
Ok, the problem is that you need to provide a component to add to your carousel.
So, you should write:
Hope this helps.Code:pattuCarousel.add(Ext.widget('panel',{ html:'<div>'+records[currentPattu].data.pattuText+'</div>' }));Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
9 Dec 2011 6:15 AM #6
Thanks for quick reply -- but error remains the same.
When check using javascript console "this" does not have "this.element" -- meaning it is null.Code:addIndicator: function() { this.indicators.push(this.element.createChild({ tag: 'span' })); },
-
9 Dec 2011 6:34 AM #7
This example I've wrote works for me.
Please take a look at the code:
Code:Ext.application({ name: 'App', launch: function() { var carousel = Ext.widget('carousel', { fullscreen: true }); Ext.regModel('Contact', { fields: ['firstName', 'lastName'] }); var store = new Ext.data.Store({ model: 'Contact', sorters: 'lastName', proxy: { type: 'memory' }, data: [ {firstName: 'Tommy', lastName: 'Maintz'}, {firstName: 'Rob', lastName: 'Dougan'}, {firstName: 'Ed', lastName: 'Spencer'}, {firstName: 'Jamie', lastName: 'Avins'}, {firstName: 'Aaron', lastName: 'Conran'}, {firstName: 'Dave', lastName: 'Kaneda'}, {firstName: 'Jacky', lastName: 'Nguyen'}, {firstName: 'Abraham', lastName: 'Elias'}, {firstName: 'Jay', lastName: 'Robinson'}, {firstName: 'Nigel', lastName: 'White'}, {firstName: 'Don', lastName: 'Griffin'}, {firstName: 'Nico', lastName: 'Ferrero'}, {firstName: 'Nicolas', lastName: 'Belmonte'}, {firstName: 'Jason', lastName: 'Johnston'} ] }); store.load({ callback: function(records, operation, success){ Ext.each(records, function(record){ carousel.add(Ext.widget('panel',{ html: record.get('firstName') + ' ' + record.get('lastName') })); }); } }); } });Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
9 Dec 2011 8:53 AM #8
Thanks. I am not sure whether your example is for Sencha 2.0 -- it does not work
"Ext.regModel has been deprecated. Models can now be created by extending Ext.data.Model: Ext.define("MyModel", {extend: "Ext.data.Model", fields: []});.
Uncaught TypeError: Cannot call method 'radioCls' of undefined
But I tried you code and added
It does not work still -- same errorCode:Ext.each(records,function(record){pattuCarousel.add(Ext.widget('panel',{html: record.get('pattuText')}));});
Thanks and Regards
Sarang


Reply With Quote