How can I add HTML data attributes to a jQuery generated <select> <option>. I have the following code which programmatically sets the <options> of a select from the results of an Ajax query.
$request.then(function (data) {
var p_id = $("[name='property_id']").val() || -1;
for (var d = 0, l = data.length; d < l; d++) {
var item = data[d];
var option = new Option(item.text, item.id, false, (item.id === p_id ? true : false));
// this doesnt work
option.data('data-owner_id') = item.owner_id;
option.data('data-property_id') = item.property_id;
$element.append(option);
}
$element.trigger('change');
});