Sencha: Usando Ext.Router fuera de la estructura MVC

I'm working on a Sencha Touch app, which currently isn't using controllers. I would like to use Ext.Router to take the visitor to a particular card in a panel. I've seen suggestions that it is possible to use the Ext.Router without using a strict MVC setup. But the example in the API looks like this (see:

map.connect('dashboard', {controller: 'home', action: 'index'});

Is there a way to, for instance, put a function into map.connect that would show a particular card in a panel?

Second question: is it even worth trying to wrestle with this, or would it be easier to update the app with controllers? (It's a pretty small app in the early stages of development, and would probably have 3 controllers if we went that route.)

preguntado el 27 de agosto de 11 a las 18:08

2 Respuestas

I had this same question and was hell bent on not using a controller because I had no time to restructure the code I was given. Like the chosen post reluctantly suggested I used the Ext.History class. If you call this in your onReady function it will activate the myPanel panel with the URL:

function initialiseHistory() {
  urlToken = Ext.History.getToken();
  if(urlToken == 'my-url-slug') {
      Ext.getCmp('tabpanel').setActiveItem('myPanel', false);

Dirty I know.. but did the job.

Respondido 26 Oct 11, 08:10

The Router is kinda married to the controller and doesn't really provide a way to do what you're asking. If what you're trying to do is show a card based on the URL hash then ya go with a controller cause its trivial to implement.. if you're hell bent on not using a controller for some reason the only thing that comes to mind is Ext.History fires a 'change' event when the url hash changes, you could listen for that event and take appropriate action I suppose.

Respondido 28 ago 11, 03:08

Thanks, this pretty much answers my question. I'll just move to using controllers. - bjudson

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.