always.amita
3 Sep 2012, 4:26 AM
Hello,
I have a app.js - that lists 2 controllers registered in my app. on load of an html, the first controller renders its associated view. On click of an item in on this view, the contentbody is replaced with contents of the other view.
Here's the issue. When the first view is loaded, the stores referred in the second controller are also fired.
i see an ajax call made. I do not want to the store to load, until i render the second view.
Also, i have a certain data in the event as id and name, (see contrller 1 below), which i need on the view 2 for its store to fire a load event. How do i pass these.?
Kindly help.
app.js
Ext.application({name: 'NewApp',
controllers:['controller1','controller2' ],
autoCreateViewport: true
});
Ext.Loader.setConfig({enabled:true});
The controller1 :
Ext.define('NewApp.controller.controller1', {
extend: 'Ext.app.Controller',
models: ['XModel','YModel'],
stores: ['XStore', 'YStore'],
refs: [
{ref: 'view1', selector: 'view1'},
{ref: 'view2', selector: 'view2'},
],
init: function() {
var me = this;
me.control({
'view1': {
itemclick : function(view, record, htmlElement, rowIndex, event, eventOpts) {
Ext.getCmp("contentsbody").remove('view1');
Ext.getCmp("contentsbody").add(Ext.create('NewApp.view.view3'));
Ext.fly('id').dom.innerHTML = event.target.id;
Ext.fly('name').dom.innerHTML = event.target.name;
}.........
Controller 2 :
Ext.define('NewApp.controller.controller2', {
extend:'Ext.app.Controller',
stores: ['store1','store2'],
models: ['model1'],
views: ['view3'],
init:function () {
var controller = this;
....events and handlers for components in view 3
}
I have a app.js - that lists 2 controllers registered in my app. on load of an html, the first controller renders its associated view. On click of an item in on this view, the contentbody is replaced with contents of the other view.
Here's the issue. When the first view is loaded, the stores referred in the second controller are also fired.
i see an ajax call made. I do not want to the store to load, until i render the second view.
Also, i have a certain data in the event as id and name, (see contrller 1 below), which i need on the view 2 for its store to fire a load event. How do i pass these.?
Kindly help.
app.js
Ext.application({name: 'NewApp',
controllers:['controller1','controller2' ],
autoCreateViewport: true
});
Ext.Loader.setConfig({enabled:true});
The controller1 :
Ext.define('NewApp.controller.controller1', {
extend: 'Ext.app.Controller',
models: ['XModel','YModel'],
stores: ['XStore', 'YStore'],
refs: [
{ref: 'view1', selector: 'view1'},
{ref: 'view2', selector: 'view2'},
],
init: function() {
var me = this;
me.control({
'view1': {
itemclick : function(view, record, htmlElement, rowIndex, event, eventOpts) {
Ext.getCmp("contentsbody").remove('view1');
Ext.getCmp("contentsbody").add(Ext.create('NewApp.view.view3'));
Ext.fly('id').dom.innerHTML = event.target.id;
Ext.fly('name').dom.innerHTML = event.target.name;
}.........
Controller 2 :
Ext.define('NewApp.controller.controller2', {
extend:'Ext.app.Controller',
stores: ['store1','store2'],
models: ['model1'],
views: ['view3'],
init:function () {
var controller = this;
....events and handlers for components in view 3
}