以下两个语句是否产生相同的输出?有没有理由偏向另一种方式?
if (key in object)
if (object.hasOwnProperty(key))
Run Code Online (Sandbox Code Playgroud) 我需要在禁用按钮上显示工具提示,并在启用按钮上将其删除.实际上它以相反的方式工作.
反转此行为的最佳方法是什么?
$('[rel=tooltip]').tooltip();
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<hr>
<button class="btn" disabled rel="tooltip" data-title="Dieser Link führt zu Google">button disabled</button>
<button class="btn" rel="tooltip" data-title="Dieser Link führt zu Google">button not disabled</button>
Run Code Online (Sandbox Code Playgroud)
这是演示:http://jsfiddle.net/BA4zM/68/
PS:我想保持属性被禁用.
html javascript jquery twitter-bootstrap twitter-bootstrap-tooltip
我是谷歌分析的几个网站的管理员.
我可以删除其中一些吗?
如果有,怎么样?
很多人建议我删除我的个人资料.所以我的怀疑是:
1.我是几个项目的管理员.我想删除其中一些.
2.如果我删除了我的个人资料,我将丢失所有项目?
我发现的许多库,如Jcrop,实际上并没有进行裁剪,它只创建了一个图像裁剪UI.然后它取决于服务器进行实际裁剪.
如何在不使用任何服务器端代码的情况下使用某些HTML5功能在客户端进行图像裁剪.
如果是,是否有一些例子或提示?
这是关于javascript提交请求的代码(1).
以下是使用jasmine(2)模拟ajax请求的测试.
我想模拟服务器行为.有任何想法吗?
有关详细信息,请参阅(1)和(2)中的注释.
PS:
实际上在两种情况下都会调用fakeFunction的done和fail Deferred Object.
(1)
submitForm: function () {
// the server execute fail only if message.val() is empty
// and I would like to mock this behaviour in (2)
backendController.submitForm(message.val()).done(this.onSuccess).fail(this.onError);
},
backendController.submitForm = function (message) {
return $.ajax({
url: 'some url',
type: 'POST',
dataType: 'json',
data: {
message: message
}
}).done(function () {
//some code;
});
};
Run Code Online (Sandbox Code Playgroud)
(2)
describe('When Submit button handler fired', function () {
var submitFormSpy,
fakeFunction = function () {
this.done = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为此模块(2)实现测试(1).
我的目的是检查在触发特定事件时是否获取集合.
正如您在(2)中的评论中所看到的,我收到消息 Error: Expected a spy, but got Function.
模块可以工作,但测试失败了.有任何想法吗?
(1)
// jasmine test module
describe('When onGivePoints is fired', function () {
beforeEach(function () {
spyOn(this.view.collection, 'restartPolling').andCallThrough();
app.vent.trigger('onGivePoints');
});
it('the board collection should be fetched', function () {
expect(this.view.collection.restartPolling).toHaveBeenCalled();
// Error: Expected a spy, but got Function.
});
});
Run Code Online (Sandbox Code Playgroud)
(2)
// model view module
return Marionette.CompositeView.extend({
initialize: function () {
this.collection = new UserBoardCollection();
this.collection.startPolling();
app.vent.on('onGivePoints', this.collection.restartPolling);
},
// other code
});
Run Code Online (Sandbox Code Playgroud) 我想从Marionette.ItemView访问app.vent.
也许一个选项可能是将参数(app.vent
)传递Marionette.ItemView
给Marionette.CompositeView
.
这是我的代码:
// view/compositeView.js
define([
'marionette',
'views/item'
], function (Marionette, itemView) {
var ListView = Marionette.CompositeView.extend({
itemView: itemView
});
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
PS:
我无法从itemView访问应用程序,因为存在循环依赖性问题.
app -> view/compositeView -> view/itemView
Run Code Online (Sandbox Code Playgroud) 我扩展了bootstrap-typeahead以获取对象而不是字符串.
它有效,但我想知道这是做事情的正确方法.
谢谢.
参考:
http
://twitter.github.com/bootstrap/javascript.html#typeahead http://twitter.github.com/bootstrap/assets/js/bootstrap-typeahead.js
_.extend($.fn.typeahead.Constructor.prototype, {
render: function (items) {
var that = this;
items = $(items).map(function (i, item) {
i = $(that.options.item)
.attr('data-value', item[that.options.display])
.attr('data-id', item.id);
i.find('a').html(that.highlighter(item));
return i[0];
});
items.first().addClass('active');
this.$menu.html(items);
return this;
},
select: function () {
var val = this.$menu.find('.active').attr('data-value'),
id = this.$menu.find('.active').attr('data-id');
this.$element
.val(this.updater(val, id))
.change();
return this.hide()
}
});
return function (element, options) {
var getSource = function () {
return {
id: 2,
full_name: 'first_name last_name'
};
};
element.typeahead({ …
Run Code Online (Sandbox Code Playgroud) 我开始使用adobe-bracket编辑JavaScript,HTML和CSS.
目前,我已经在侧栏中打开了"入门"项目.我想创建一个新项目,但文件菜单中没有这样的"新建项目"项.
我尝试点击"项目设置",但这只是给了我:
你如何摆脱默认的"入门"项目,并开始一个全新的项目?
javascript ×8
jquery ×4
backbone.js ×2
jasmine ×2
marionette ×2
autocomplete ×1
editor ×1
html ×1
html-editor ×1
html5 ×1
html5-canvas ×1
post ×1
tooltip ×1