<!DOCTYPE html>
<
html
>
<
head
>
<
title
>BackboneJS Model off</
title
>
<
script
src
=
type
=
"text/javascript"
>
</
script
>
<
script
src
=
type
=
"text/javascript"
>
</
script
>
<
script
src
=
type
=
"text/javascript"
>
</
script
>
</
head
>
<
body
>
<
h1
style
=
"color: green;"
>
GeeksforGeeks
</
h1
>
<
h3
>BackboneJS Model off</
h3
>
<
script
type
=
"text/javascript"
>
var myVal = Backbone.Model.extend(
{ name: 'Hello Guys' }, Backbone.Events);
var myFunc = function () {
document.write('This is by first callback <
br
>');
};
var myFunc1 = function () {
document.write('This is by second callback <
br
>');
};
var myFunc2 = function () {
document.write('This is by third callback <
br
>');
};
myVal.on('log', myFunc);
myVal.on('log', myFunc1);
myVal.on('log', myFunc2);
document.write("Before Removing myFunc callbacks"
+ " for all events. <
br
>")
myVal.trigger('log');
myVal.off(null, myFunc);
document.write("<
br
>After Removing all callback "
+ "for log events nothing will print <
br
>")
myVal.trigger('log');
myVal.off();
document.write("<
br
> Remove all the "
+ "callbacks of myval model ");
myVal.trigger('log');
</
script
>
</
body
>
</
html
>