mardi 26 mai 2015

Can't attach jQuery Plugins that is inside {{#if}} in EmberJS

In my emberjs app. I have bunch of jquery plugins that I need to bind to various elements.

I am using this piece of code to initiate jquery plugins for elements.

App.ApplicationView = Ember.View.extend({
    didInsertElement: function(){
        window.appPluginsInit(); // all jquery plugin init

        // chart client init
        var chartClientSettings = {
            serverUrl: config.ajaxUrl
        };

        this.$('.chart-client').chartClient(chartClientSettings);
    }
});

This only works for element that are initially loaded to the page. But for example if an element is under {{#if}} it doesn't seem to be attached with plugins.

Works

<button class="chart-client">Show Chart</button>

Doesn't work

Considering the someVar is false on initial load.

{{#if someVar}}
<button class="chart-client">Show Chart</button>
{{/if}}




Aucun commentaire:

Enregistrer un commentaire