I have a button to which I want to connect a click listener, but every time the code starts, it gives a console error
jquery.js:4435 Uncaught TypeError: ((n.event.special[g.origType] || (intermediate value)).handle || g.handler).apply is not a function
Here the js code that triggers the error, the first line works fine, the second line causes an error
$toolbar.off('click', '.btn-save'); // $toolbar is assigned $("#toolbar") on init $toolbar.on('click', '.btn-save', function(e){ saveData(0); });
What bothers me, if I run this bit of code manually through the console, I get no errors
Here is the HTML
<div class="row" id="toolbar"> <div class="col-lg-12"> <button type="button" class="btn btn-primary btn-save">Save</button> <button type="button" id="btnCancel" class="btn btn-default btn-cancel">Cancel</button> </div> </div>
source share