- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在运行 ember-1.0.0-rc.5 并为我传递文章 ID 的 disqus 评论创建了一个 View 。
我的问题是 disqus 不知道我何时从一页切换到另一页。
这是 View 代码:
App.DisqusView = Ember.View.extend({
tagName: 'div',
elementId: 'disqus_thread',
didInsertElement: function(){
var root_url = "http://my-root-url.herokuapp.com"
var page_id = this.get('identifier');
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_identifier = "item-" + page_id;
console.log(disqus_identifier);
/ this outputs the correct id/
var disqus_title = "the song title" ;
console.log(disqus_title);
/ this outputs the correct title/
var disqus_url = root_url + '/#/song/' + page_id;
console.log(disqus_url);
/ this outputs the correct url for the page/
var disqus_shortname = 'example';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
}
});
{{view App.DisqusView identifierBinding="id"}}
DISQUS assertion failed: Unsafe attempt to redefine existing module: stringify [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: parse [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: domready [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: on [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: once [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: off [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: trigger [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: stopListening [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: listenTo [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: listenToOnce [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: bind [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: unbind [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: getShortnameFromUrl [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: getForum [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: isSSL [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: guessThreadTitle [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: getContrastYIQ [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: colorToHex [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: getElementStyle [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: getAnchorColor [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: normalizeFontValue [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: isSerif [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: getBrowserSupport [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: getPermalink [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: expose [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: BaseApp [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: WindowedApp [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: ThreadBoundApp [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: PublicInterfaceMixin [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: Switches [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: Profile [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: BackplaneIntegration [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: Lounge [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: Ignition [VM] embed.js (16737):1
DISQUS assertion failed: Unsafe attempt to redefine existing module: HostConfig
最佳答案
将 Disqus 与 Ember 集成
更新 - 现在有一个 Ember Addon here .
我刚刚在 ember 博客框架 ( see source here ) 上集成了异步 Disqus,我是这样做的:
首先,将选项设置为一个对象(所有组件都可以轻松访问):
App.DisqusOptions = Em.Object.create({
shortname: 'example', // Set this to your Disqus account's shortname
});
App.DisqusCommentsComponent = Em.Component.extend({
setupDisqus: function() {
if (!window.DISQUS) {
var disqusShortname = App.DisqusOptions.get('shortname');
window.disqus_shortname = disqusShortname; // Mimic behaviour as if we're setting variable in a script tag
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqusShortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}
}.on('didInsertElement'),
});
disqusLoaded
来做到这一点。运行
setupDisqus()
后,选项对象上的属性为 true方法并进行检查。
script
在您的应用程序模板中执行此操作。标签,但如果您在没有
id
元素的页面上加载脚本,这会导致错误。的
#disqus_thread
.
Em.View
或
Em.Component
您将放置在您希望评论出现的每个页面上。我们叫它
App.DisqusCommentsComponent
.此组件将没有布局(模板)。由于每次我们更改路线/帖子时都会加载此组件,因此这是调用
DISQUS.reset()
的理想场所.
App.DisqusCommentsComponent = Em.Component.extend({
elementId: 'disqus_thread', // ID is used by Disqus to know where to load the comments
timer: null,
setupDisqus: function() {
// setupDisqus() code left out for purposes of not repeating myself
}.on('didInsertElement'),
loadNewPostComments: function() {
if (window.DISQUS) {
this.reset();
} else {
// If DISQUS hasn't finished async loading yet, check again in 100 ms. Once it's loaded, the above this.reset() will be called.
this.set('timer', Em.run.debounce(this, this.loadNewPostComments, 100));
}
},
reset: function() {
var controller = this.get('parentView.controller');
var postIdentifier = controller.get('urlString');
var postUrl = window.location.href;
// Since this view has the elementId Disqus targets, we need to wait until after the view has finished rendering to call the reset function, which searches for #disqus_thread
Em.run.scheduleOnce('afterRender', function() {
window.DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = postIdentifier;
this.page.url = postUrl;
}
});
});
},
});
postIdentifier
是在 Controller 上为每个博客文章设置的属性,作为 Controller 的模型加载。您将需要一种类似的方法来识别每条路线以跟踪评论。
// Some random hbs here for your blog post
{{disqus-comments}}
var disqusShortname = App.DisqusOptions.get('shortname');
window.disqus_shortname = disqusShortname;
// Do stuff with disqusShortname here
{{link-to}}
helper 调用类似于以下内容:
Em.LinkView.reopen({
addDisqusTag: function() {
var commentCount = this.get('commentCount');
if (commentCount) {
var isLinkToPost = this.get('isLinkToPost');
var href = this.get('href');
var disqusTag = '#disqus_thread';
this.set('href', href + disqusTag);
}
}.on('willInsertElement'),
});
{{#link-to 'post' this.urlString commentCount='true'}}{{/link-to}}
关于ember.js - 将 disqus 与 emberjs 集成仅适用于第一页加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17634034/
SCENARIO 有两页,第一页是HomePage,它在flutter_bloc软件包的帮助下自动获取api数据。在首页(第一页)中,还有一个按钮,可在此代码Navigator.push(contex
我检查过类似的问题,但由其他人发布,但我仍然看不到我的代码有什么问题。 我刚刚从文档中复制了它 - https://symfony.com/doc/3.4/page_creation.html Luc
我已经编写了一段代码,使用Python中的Scrapy来抓取页面。下面我粘贴了 main.py 代码。但是,每当我运行我的蜘蛛时,它仅从第一页抓取(DEBUG:从抓取),这也是请求中的Referer标
我创建了一个 ios 图书阅读器应用程序。在这个应用程序中,我集成了 google drive 和 skydrive 。现在我可以从 google drive 和 skydrive 登录和检索数据了。
效果图: 功能简介:可使用上下键选中行,选中后点击修改,textbox获得gridview中的代码的数据。对你有帮助的话,请记得要点击“好文要顶”哦!!!不懂的,请留言。废话不多说了,贴码如下
我是一名优秀的程序员,十分优秀!