View Full Version : How to use controllers MVC in a view for call a function

13 Sep 2011, 5:50 AM

i would like to use MVC for my first application with Sencha. I'm trying to implement the controllers for having a showMap function, who will get the location informations and display the map

But calling the controllers don't work in my View.
I have app/app.js ; app/controllers/AppCurrentPosCtl.js ; app/views/CurrentPos/AppInfoCurrentPos.js
and app/views/Viewport.js

initComponent: function() {
Ext.apply(this, {
items: [
{xtype: 'appInfoCurrentPos'},
{xtype: 'appMapCurrentPos'},
myApp.views.Viewport.superclass.initComponent.apply(this, arguments);

Viewport just call all my views.

myApp.views.AppInfoCurrentPos = Ext.extend(Ext.Panel, {
title: 'Infos',
iconCls: 'info',
dockedItems: [{
xtype: 'toolbar',
title: 'Your Current Position -infos-',
dock: 'top',
items: [{
ShowInfosCurrentPos: function () {
controller: myApp.controllers.appCurrentPosCtl,
action: 'showInfos',
scroll: 'vertical',
fullscreen: true,
initComponent: function() {
myApp.views.AppInfoCurrentPos.superclass.initComponent.apply(this, arguments);

Ext.reg('appInfoCurrentPos', myApp.views.AppInfoCurrentPos);

This is AppInfoCurrentPos.js where i'm trying to call the controllers

views: [

showInfos : function() {
alert("ctl works");

myApp.controllers.appCurrentPosCtl = Ext.ControllerManager.get('AppCurrentPosCtl');
And This is The controllers.
I just try to read an alert for the moment.

I try to use this on safari / chrome, not on devise for the moment.

Someone can explain me how to use MVC in Sencha please? :)
I tried to find on the forum, but without success. Some exemples how don't work.

Thanks for your help

22 Dec 2011, 8:01 AM
Do you have a solution for that? I ran into this issue now. Thanks