I'm wondering if calls to $(".domElement").data("key", "newValue")
will trigger an event that I can handle? I've tried binding change
but this doesn't get triggered when data is set.
I think this question may be asking something similar, but binding changeData
didn't work either - jQuery data() and 'changeData' event.
Actually you have only tried to attach the custom event but you will also have to trigger it something like:
$('button').click(function (e) {
$('#someID').data("key", "newValue").trigger('changeData');
});
$('#someID').on('changeData', function (e) {
alert('My Custom Event - Change Data Called! for ' + this.id);
});
FIDDLE DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With