最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Ext JS - How to get name of application from within ViewModel? - Stack Overflow

programmeradmin1浏览0评论

My Dr. Evil application has name defined as DrEvil:

Ext.define('DrEvil.Application', {
    extend: 'Ext.app.Application',

    name: 'DrEvil',

    stores: [
        // TODO: add global / shared stores here
    ],

    launch: function () {
        // TODO - Launch the application
    }
});

In my view model, is there a way to retrieve this name? I was hoping something like Ext.app.name would pull it up but it es up empty. I've been iterating through properties of Ext, Ext.app etc. and can't seem to find it.

This is probably something so trivial that it's looking me right in the face, but I did google N variations of ExtJS get name of application within view model with nothing relevant ing up.

I'm trying to convince the pany to purchase the Eclipse plugin for ExtJS! Could probably answer this question in a second.

My Dr. Evil application has name defined as DrEvil:

Ext.define('DrEvil.Application', {
    extend: 'Ext.app.Application',

    name: 'DrEvil',

    stores: [
        // TODO: add global / shared stores here
    ],

    launch: function () {
        // TODO - Launch the application
    }
});

In my view model, is there a way to retrieve this name? I was hoping something like Ext.app.name would pull it up but it es up empty. I've been iterating through properties of Ext, Ext.app etc. and can't seem to find it.

This is probably something so trivial that it's looking me right in the face, but I did google N variations of ExtJS get name of application within view model with nothing relevant ing up.

I'm trying to convince the pany to purchase the Eclipse plugin for ExtJS! Could probably answer this question in a second.

Share Improve this question edited Apr 10, 2018 at 11:36 Glorfindel 22.7k13 gold badges90 silver badges119 bronze badges asked Jul 10, 2015 at 17:46 user2191247user2191247
Add a ment  | 

3 Answers 3

Reset to default 6

It's actually not obvious at all if you assume no knowledge of the application.

This is generic code which will do what you want:

var name = Ext.app.Application.instance.getName();

Or in recent versions of ExtJS:

var name = Ext.getApplication().getName();

You are looking to get the application namespace.

DrEvil.app.getApplication().getName()

If you're using Ext 4+ and create your application using the Ext.application syntax like so, there will be a reference to your application in the global namespace:

Ext.application({
    name: 'DrEvil',
    launch: function() {
        // do some stuff
    }
});

http://docs.extjs./extjs/4.1.3/#!/api/Ext.app.Application

At this point, DrEvil should be defined in the global scope. Now, you should be able to reference the application name as a string via DrEvil.getApplication().name, though that might be a bit redundant for what you're looking to do.

Hope this helps.

发布评论

评论列表(0)

  1. 暂无评论