There is a backbone view and it has some events for particular classes. let's say html will be like this.
<div class=""some1">
<a href="#" class="inner1"> Loaction 1 </a>
<a href="#" class="inner2"> Loaction 2 </a>
<a href="#" class="inner3"> Loaction 3 </a>
// All possible hierarchy goes here , like combination of div , a, span
// and every tag has class
// for classes there will be backbone view
<input class="inputclass" type="text"> // input submission
</div>
and lets say backbone view will be
//sampleView.js
template: '_SampleHtml',
events: {
"click .inner1": "clickinner1",
"click .inner2": "clickinner2",
"click .inner3": "clickinner3",
"click .inner4": "clickinner4",
...
....
......
"click .inputclass": "inpputclass",
},
clickinner1: function() {
//do something
},
clickinner2: function() {
//do something
},
clickinner3: function() {
//do something
},
clickinner4: function() {
//do something
}
inpputclass: function() {
// if input is having one particular condition
// i want to remove all the events i.e only 'onclick ' should not work on view,
//means even if you click 'Loaction 1 ' , respective event should not occur
// and contents should be present on DOM
}
I tried " unbind() "," off" ," stopListening() "," delegate events in Backbone". nothing has worked for my criteria. when I used delegates, contents are removing from DOM. Is there any method to remove all events which comes under particular div. like "some1"?
PS: I am attaching an image, where I occurred this problem. Please follow to get exact idea.
您可以使用undelegateEvents
从视图中删除所有事件侦听器
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.