简体   繁体   中英

Ember.js with a third party theme template

I would like to use Ember.js with a website template from Themeforest (with html, css and js files).

A problem with the main Javascript file from the template is that it is called only one time when the document is ready, but I would like to call it each time a user change his route.

For example, each time a new route is called, there is a new <div class="page-content"></div> , but the following jQuery line is not executed.

$('.page-content').wrapInner('<div class="page-content-inner"></div>');

Do you have any idea to solve this issue with a clean way? I don't want to change every line of the main Javascript file of the template that has about 1200 lines.

Thank you for your help

You could use this example from the Ember docs on how to add Google analytics tracking on every transition.

App.Router.reopen({
  notifyGoogleAnalytics: function() {
    return ga('send', 'pageview', {
        'page': this.get('url'),
        'title': this.get('url')
      });
  }.on('didTransition')
});

The code above would get run each time you transition between routes, and you could just define it in one place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM