Open
Conversation
touchjs v0.2.14调用off函数解除事件绑定,发现无效,遂做此提交,本次提交修复了事件不能解绑以及事件委托不能解绑的问题。
|
你这个版本也无法解除绑定啊~ if (changan == 1) { |
Author
|
@jiayouzl 报什么错呢? |
|
Uncaught TypeError: Cannot read property 'hold' of undefined |
2 similar comments
|
Uncaught TypeError: Cannot read property 'hold' of undefined |
|
Uncaught TypeError: Cannot read property 'hold' of undefined |
Author
touch.on('.content', 'hold', function(ev){
console.log('长按');
});
touch.off('.content', 'hold');你先试试这样看能不能解绑成功 |
|
<title>长按事件</title>
<script type="text/javascript" src="./touch-0.2.14.js"></script>
长按我吧
绑定
解绑
<script type="text/javascript">
function bangding() {
touch.on('.content', 'hold', function(ev){
console.log(this.innerText);
});
}
function jiebang() {
touch.off('.content', 'hold', function(ev){
console.log('解绑成功!');
});
}
</script>
你刚才说的也试了也不行~@luocong123 |
Author
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
html,body{
width: 100%;
height: 100%;
background: #f5f5f5;
-webkit-touch-callout:none;
}
</style>
</head>
<body class="content">
<script src="touch.js"></script>
<script>
touch.on('.content', 'hold', function(ev){
console.log('长按');
ev.preventDefault();
});
// touch.off('.content', 'hold');
</script>
</body>
</html>我试了试,能解绑啊,把解绑注释掉,长按事件就生效,不注释的话,长按事件就不会生效 |
并不能解绑啊。。。是我哪里写错了吗 找到原因了,无法解绑是因为没有调用到正确版本的文件。 |
Author
|
这个项目没人维护了,所以提交代码这么长时间也没人合并过去,所以想解绑的同学就像 @zzhao5 那样自行去拷贝这个版本 v0.2.14 2015-11-10 支持解绑版本 的代码吧 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
touchjs v0.2.14调用off函数解除事件绑定,发现无效,遂做此提交,本次提交修复了事件不能解绑以及事件委托不能解绑的问题;本次提交未修改压缩版。