没有事件直接绑定到DOM [英] Bind directly to DOM with not event
本文介绍了没有事件直接绑定到DOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下jQuery:
I have the following jQuery:
$('#big-bad-bold-button')
.on('click', aloha.ui.command(aloha.ui.commands.bold));
它绑定click
事件.如何无需单击即可实现相同的绑定?
It binds the click
event. How could I achieve the same binding without having to click?
我想以编程方式调用该函数并执行与DOM的绑定,而无需单击.
I want to call programatically the function and perform the binding to the DOM without having to click.
UPDATE :我使用StackBox的以下解决方案创建了一个JSBin: http://jsbin.com/kofire/3/
推荐答案
看来 aloha.ui.command 是一个高阶函数,我想你可以
It seems that aloha.ui.command is a higher order function, I think you can
使用如下代码:
aloha.ui.command(aloha.ui.commands.bold)($('#big-bad-bold-button'))
咖喱是一件有趣的事情:
Curring is an intereseted thing:http://en.wikipedia.org/wiki/Currying
这篇关于没有事件直接绑定到DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文