Closed afarber closed 4 years ago
I cannot assign it from an external/inline JavaScript code, do I?
It's possible, but you have to take a small detour. You could create
<div class="parent">
<div data-myprop="1">Test</div>
<div data-myprop="2">Tast</div>
</div>
And since you're using jQuery:
$(".parent").on("click", "[data-myprop]", function (event) {
alert($(this).data("myprop"));
});
This way you only have 1 listener too (instead of 1 for each element).
Since your case is an input field, you could add class to it (ex, "my-input"), and just do:
$(".my-input").on("click", function (event) {
alert($(this).val());
});
Thanks, I get your point. For my case I have solved it with
jQuery(document).ready(function($) {
$('input[type="button"]').click(function(){
toggleMid(this.value);
});
$('#puzzles').accordion({
header: 'h3'
});
});
Hello,
I have started using j2html 1.4.0 few days ago for a servlet and the API is really nice - nothing like the other APIs I have reviewed for the purpose of creating HTML code in a Java servlet.
However while I have noticed the advice in the issue #137 I do not understand how to apply it to my case: I fetch a long list from a database and then create an input button for each record:
The resulting list I display in jQuery UI Accordion:
My problem is that each input element has an ONCLICK="toggleMid(this.value)" attribute
I cannot assign it from an external/inline JavaScript code, do I?
Thanks Alex