I use an input field to submit 2 pieces of data to an event handler: the displayed value and a property value.
When I populate the data, I do this:
xInput.val('ARC'+opts[0].arc);
xInput.prop('data-sine',opts[0].sine);
// Now, trigger submit-handler
xInput.show();
xInput.trigger('change');
When I stop in the debugger, I can see that the property data-sine
exists on the jQuery object and has the correct data.
Now, in the change event, I want to move the data from the "element" onto the event so the astrosearch API invocation can pick it up using a generic event handler, which also handles input from a <SELECT>
tag in cases where there is more than one arc to choose from. So, I do this:
xInput.on('change', function (e) {
e.sine = $(this).attr('data-sine');
astrofinder.findAstro(e, true);
astrofinder.ui.countdown.start(function () { xInput.trigger('find'); });
});
When I stop at the first line here, this
is NOT the xInput
jQuery object, it's the raw HTML element - BUT the element DOES NOT HAVE a data-sine
property! Somehow, it didn't make it out of jQuery into the DOM?
Why? Do I need to use a timer to get into the next event loop?