Jump to content

Jquery migrate jquery-1.8.1.min.js to jquery-3.1.1.min.js (.live replace with .on)


Girish Dubey

Recommended Posts

I am trying to bind dynamic event but i am not able to bind. previously i have used .live in our system that was working find now we are going to migrate our system to jquery 3.1.1. and i have replace all .live to .on function but work. for you reference..

 

 

<html>
<head>
<script src="jquery-3.1.1.min.js"></script>
<!-- <script src="jquery-1.8.1.min.js"></script> -->
<script>

var abcHandler = function() {
var h=this;
h.getControl = function(cntrl) {
return $("[class$='Cntrl_" + cntrl + "']");
};
h.main = h.getControl('main');
h.divid1 = h.getControl('divid1');
h.divid2 = h.getControl('divid2');
}


abcHandler.prototype.BindEvents = function() {
var h=this;


h.main.append("<a class='Cntrl_divid1' href='#'>View Details1</a><br />");
h.main.append("<a class='Cntrl_divid2' href='#'>View Details2</a>");

h.divid1.click(function () {
alert(this.innerHTML);
});

h.divid2.click(function () {
alert(this.innerHTML);
});
};


var handler;
$(document).ready(function() {
    handler = new abcHandler();
    handler.BindEvents();
});


</script>
</head>
<body>
<div class="Cntrl_main">
</div>
</body>
</html>

Please suggest me how i can fix this issue.

 

 

das

Edited by Girish Dubey
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...