我试图将事件绑定到textbox
包含参数的事件.以下看起来好像应该这样做,但每次页面加载时,它都会被执行.
jQuery(function(){
jQuery('#textbox').bind('click', EventWithParam('param'));
});
Run Code Online (Sandbox Code Playgroud)
每次页面加载时都会使用该参数调用该事件.这可能不起作用,因为不支持带参数的事件.如果是这样,还有另一条路线吗?
我一直在努力解决这个问题.我正在使用这个代码来监控鼠标滚轮,因此它可以用于我使用的滑块进行滚动..但是,它有一个问题,操作排队等等如果你用鼠标滚动快速滚动(就像任何人会正常做的那样)它们会累积并导致错误的行为.我知道用动画来处理这类问题,但不是用鼠标滚轮监视器.
I want to do something like unbind the mousewheel at the start of the action (in this case, to scroll the scrollbar after mousewheel is moved) then rebind it after this, so if user does too many scrolls too fast it just ignores until the initial scroll is completed.. I tried the code below but its not rebinding so I'm not sure what I am doing wrong, any advice is appreciated.
$("#wavetextcontainer").bind("mousewheel", function(event, delta) {
//HERE IS WHERE EVENT …
Run Code Online (Sandbox Code Playgroud) 我已经看过类似的问题,但提供的答案涉及按钮而不是div元素.当我单击带有id的div元素时click
,单击事件处理程序将被禁用,unbind()
并将计时器设置为2秒.2秒后,应再次启用click事件处理程序bind()
.问题是click事件处理程序似乎没有"反弹".我将文本附加到另一个div元素以检查click事件处理程序是否处于活动状态.
这是我的jsfiddle:
客户端可以使用bindService()
/ 调用原始绑定/解除绑定服务unbindService()
.
我的问题是如何在服务端取消绑定服务,而不是unbindService()
客户端调用,可能我应该调用它unbindClient
.
我认为服务应该知道哪些客户端绑定了它,那么有没有办法告诉服务取消绑定特定客户端?
因为我只写服务,我不知道客户端unbindService()
是否正确调用,所以我有这个问题..
我有一个奇怪的问题,我有代码通过ajax拉取内容,然后将Fancybox(2)绑定到某些元素.问题是,当我"刷新"这个页面时,我会调用相同的函数来再次拉动和绑定Fancybox.
直到我改为Fancybox 2之前一直在努力的正常方法是取消绑定元素并重新绑定它们.然而,这似乎不适用于FB2.
我尝试过以下方法:
$('.tool_button').unbind('click.fb');
$('.tool_button').unbind('click');
$('.tool_button').unbind();
$('.tool_button').off('click.fb');
$('.tool_button').off('click');
$('.tool_button').off();
Run Code Online (Sandbox Code Playgroud)
我确实注意到源文件中的以下内容可能有用(起始行652):
// Unbind the keyboard / clicking actions
unbindEvents: function () {
if (F.wrap && isQuery(F.wrap)) {
F.wrap.unbind('.fb');
}
D.unbind('.fb');
W.unbind('.fb');
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以在这里提供帮助,我将不胜感激.
提前致谢.缺口
从Python语言参考(v 3.1,请参阅此处 - http://docs.python.org/py3k/reference/executionmodel.html#naming-and-binding):
取消绑定封闭范围引用的名称是非法的; 编译器将报告一个SyntaxError.
但是当我运行以下代码时:
a = 3
def x():
global a
del(a)
print(a)
x()
Run Code Online (Sandbox Code Playgroud)
它工作正常; 当我改变通话顺序时:
x()
print(a)
Run Code Online (Sandbox Code Playgroud)
我得到一个NameError,而不是SyntaxError.显然,我不能正确理解规则.有人能解释一下吗?谢谢.
我想要做的是在运行一次之后取消绑定特定的功能.在下面的代码中,它是窗口滚动.
$(window).scroll(function(){
if($(window).scrollTop() == viewportheight ){
$("#landing_page").fadeOut(function() { $(window).scrollTop(0); $(window).unbind("scroll");});
}
});
Run Code Online (Sandbox Code Playgroud)
基本上,当#div淡出时,我希望它滚动(0).滚动顶部后,我需要整个功能解除绑定.
有没有办法给这个函数一个特定的名字,然后回调那个名字?因为此代码有效,所以只删除所有滚动功能.(我不想要的事情)我在想这样的事情:
$(window).scroll(function(FUNCTION NAME HERE){
if($(window).scrollTop() == viewportheight ){
$("#landing_page").fadeOut(function() { $(window).scrollTop(0); $(window).unbind("FUNCTION NAME HERE");});
}
});
Run Code Online (Sandbox Code Playgroud) 我有2个活动,A和B.服务从B开始,带有这样的代码:
startService(new Intent(this, PlayerService.class));
Intent connectionIntent = new Intent(this, PlayerService.class);
bindService(connectionIntent, mp3PlayerServiceConnection, Context.BIND_AUTO_CREATE);
private ServiceConnection mp3PlayerServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName arg0, IBinder binder) {
mp3Service = ((LocalBinder) binder).getService();
Thread t = new Thread() {
public void run() {
mp3Service.playSong(getApplicationContext(),url);
}
};
t.start();
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
}
};
Run Code Online (Sandbox Code Playgroud)
当我在活动A(B关闭但音乐播放)时,我需要有可能关闭服务.如何从A onDestroy()调用StopService?需要我解开它,如果是的话,如何以及在哪里?
简单地将stopService(new Intent(this,PlayerService.class));
导致错误:活动B已泄露服务连接...最初绑定在这里.(但B已经关闭)
html
<a href="home.html">Home</a>
Run Code Online (Sandbox Code Playgroud)
css
a {
color: blue;
}
a:hover {
color: red;
}
Run Code Online (Sandbox Code Playgroud)
现在你可以看到<a>
现在悬停时颜色为红色。
问题
如何通过 jQuery 删除悬停?
我试过:
$('a').unbind('hover');
和$('a').unbind('mouseenter mouseleave')
我开始想为什么它不起作用,不是hover()
吗?
我尝试使用EasyMotion
插件,但我不想使用普通的leader key
,\
在我的情况下是-key.我也不打算一起改变leader key
所有这些,因为它可能会破坏一切vim-latex
.
所以我考虑使用period
-key(我已经使用comma
-key进入command-line
模式),因为我从未真正使用它的重复功能:
这是我迄今为止在.vimrc中尝试过的:
nunmap .
let g:EasyMotion_leader_key = '.'
Run Code Online (Sandbox Code Playgroud)
第二个命令看似很好.但是我不能用第一个命令取消绑定句点键(E31:没有这样的映射).如果我错了只想period
在正常模式下取消绑定-key,那么请随时纠正我.
任何想法都表示赞赏!
unbind ×10
jquery ×5
bind ×3
android ×2
service ×2
destroy ×1
fancybox ×1
fancybox-2 ×1
function ×1
javascript ×1
key ×1
mousewheel ×1
period ×1
python ×1
scrolltop ×1
settimeout ×1
syntax-error ×1
vim ×1