- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
有没有办法让同一对象(例如文本框)的其他绑定(bind)事件先触发/触发?
假设 2 个事件绑定(bind)到同一个文本框。两个 keyup 事件。在我的例子中,有一个插件绑定(bind)了它自己的事件,但是代码的编写方式,我的首先被绑定(bind)。我不想让我的先开火。
$("#firstname").keyup(function() {
// ...is there anyway to allow the other keyup event to fire first, from here?
// do my work here...
}
$("#firstname").keyup(function() {
// the plugin work.
}
我需要使用keyup,已经有key down事件了。
最佳答案
你真的应该重写你的代码,让只有一个 keyup 绑定(bind)到那个事件,但如果那不可行,你可以用信号量来做它,并将你的功能与绑定(bind)分开,这样它就可以从任一绑定(bind)调用.. .
var semaphore = 0; // on init
$("#firstname").keyup(function () { // this one should run first
semaphore++;
if (semaphore === 0) {
first_action();
}
}
$("#firstname").keyup(function () { // this one should run second
if (semaphore > 1) { // you know the first event fired
second_action();
}
else if (semaphore < 1) {
first_action();
second_action();
semaphore++;
}
}
关于javascript - 让其他绑定(bind)的元素事件先触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7744838/
几个月前,我做了一个功能,我的应用程序正在等待用户文档并做出相应的响应。直到我对项目进行优化并将其更新到最新版本之前,它一直是一种魅力。 如果存在用户文档,则流将产生该文档并关闭该流。 如果云Fire
Stack Overflow 有几个 examples其中函数首先获得可升级锁,然后通过升级获得独占访问。我的理解是,如果不小心使用,这可能会导致死锁,因为两个线程可能都获得了可升级/共享锁,然后都尝
这个问题在这里已经有了答案: MVC 4 Code First ForeignKeyAttribute on property ... on type ... is not valid (1 个回答
以下是部分代码。我需要在 finally 子句中关闭资源。我需要先调用 closeEntry() 还是 close()?我收到一些错误消息。 Error closing the zipoutjava.
我想使用 RxJS-DOM 观察 mousewheel 事件,这样当第一个事件触发时,我转发它然后删除所有值,直到后续值之间的延迟超过先前指定的持续时间。 我想象的运算符可能看起来像: Rx.DOM.
版本似乎与安装的不同。 我在 npm install 上收到警告 我将二进制文件安装到我的家庭/开发目录中,但它不适用于 sudo。所以我安装了apt。 (注意:我并没有真正安装,我提取并将路径放在/
我正在尝试展示 GAN 网络在某些指定时期的结果。打印当前结果的功能以前与 TF 一起使用。我需要换成 pytorch。 def show_result(G_net, z_, num_epoch, s
我是一名优秀的程序员,十分优秀!