简体   繁体   English

带有第三方主题模板的Ember.js

[英]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). 我想将Ember.js与Themeforest的网站模板一起使用(带有html,css和js文件)。

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. 模板中的主要Javascript文件的问题在于,当文档准备就绪时,它仅被调用一次,但是我想在用户每次更改其路线时都调用它。

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. 例如,每次调用新路由时,都会有一个新的<div class="page-content"></div> ,但是不会执行以下jQuery行。

$('.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. 我不想更改具有约1200行的模板的主Javascript文件的每一行。

Thank you for your help 谢谢您的帮助

You could use this example from the Ember docs on how to add Google analytics tracking on every transition. 您可以使用Ember文档中的此示例 ,了解如何在每次转换时添加Google Analytics(分析)跟踪。

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. 每次在路线之间转换时,上面的代码都会运行,您只需将其定义在一个位置即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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