ViewController can not listen beforerender event?

398 views
Skip to first unread message

cqul...@gmail.com

unread,
Apr 16, 2014, 9:46:41 AM4/16/14
to def...@googlegroups.com
hi.I am new to Deft JS, I try to listen a window's beforerender event in view config but I fail.
code:
control: {
        view: {
            beforerender: "onBeforerender"
        },
        submit: {
            click: "onButtonClickSubmit"
        }
}

log:
[I] Adding 'beforerender' listener to 'null'.
[I] Adding 'submit' component reference for selector: '#submit'.
[I] Adding component selector for: '#submit'.

can someone help me?


Brian Kotek

unread,
Apr 16, 2014, 10:05:17 AM4/16/14
to deftjs
Yes, that's correct. The ViewController's view setup happens after the render event on Ext JS, and initialize on Touch. Deft supports both Ext and Touch, and those are the only events we can listen for to be sure that the child components exist (so control block component getters work, that all view listeners can be set up, and so on).


--
Deft JS home page: http://deftjs.org/
Wiki: https://github.com/deftjs/DeftJS/wiki
For rules and tips on asking questions on the Deft JS mailing list: https://github.com/deftjs/DeftJS/wiki/Asking-Questions-on-the-Mailing-List
---
You received this message because you are subscribed to the Google Groups "Deft JS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deftjs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deftjs/48a61d24-47d5-49c9-887e-5167eae401dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Kotek

unread,
Apr 16, 2014, 10:23:46 AM4/16/14
to deftjs
Out of curiosity, what are you trying to do? Just asking in case there's actually an easier way to do what you're looking for.

Jean-Marc Choulet

unread,
May 25, 2014, 2:35:50 AM5/25/14
to def...@googlegroups.com
Hello Brian,

I have the same problem. I want to choose the language for the text button property in the beforerender event. In my function, I have this code :

    onSplitbuttonBeforeRender: function(abstractcomponent, options) {
        var lang = localStorage ? (localStorage.getItem('user-lang') || 'en') : 'en';
        abstractcomponent.iconCls = lang;

        if (lang == 'fr') {
            abstractcomponent.text = 'Français';
        } 
        else {
            abstractcomponent.text = 'English';
        } 
    },

How can I do that ?

Thanks,

Jean-Marc

Jean-Marc Choulet

unread,
May 25, 2014, 6:59:40 AM5/25/14
to def...@googlegroups.com
Well, I added a listener for the beforerender in my view. Is it correct ?

Ext.define('MyApp.view.menu.Accordion', {
    ...

    requires: [ "MyApp.controller.MenuController" ],
    controller: "MyApp.controller.MenuController",

    listeners: {
        beforerender: function(abstractcomponent, options) {
            this.getController().onPanelRender(abstractcomponent, options);
        }
    },

    ...
});

Thanks,

Jean-Marc

Brian Kotek

unread,
May 25, 2014, 8:10:55 PM5/25/14
to deftjs
Why do you need to change the text before render? You can just call button.setText('whatever') any time you want to change the text.


Reply all
Reply to author
Forward
0 new messages