So my problem is, I want to run some jQuery-Code when the Button is clicked.
<input type="button" name="appointments_view" value="Alle Termine anzeigen" />
Here is my jQuery-Class (For testing, the Listener should print out something on the console.)
"use strict";
$.Class("View", {
init : function() {
$("[name='appointments_view']").click(function() {
console.log("appointments_view");
});
}
});
If i run it in the browser, Firebug isn’t giving me any errors. When i click the Button, nothing happens.
Putting the Listener in a $(document).ready() function doesn’t help.
Thanks in advance for any help!
My Problem was, that the HTML was loaded with AJAX (the .load() function).
Although the .load() was written before (!) the listener, the button didn’t respond.
The solution is, to write the listener in the callback-function of the .load()-function.
See here:
dynamically add listener to ajax created content in jQuery