I'm using HTML 5 data attributes to key rows of data in a table. I need to iterate the rows and gather the data into an object collection. I created a class to represent my row data:
function SomeItem(description, finalPrice, percentDiscount) {
this.Description = description;
this.FinalPrice = finalPrice;
this.PercentDiscount = percentDiscount;
}
An event fires which triggers the collection of this data.
$.each($('.ItemPriceBox'), function () {
var uniqueid = $(this).data('uniqueid');
var finalPrice = $(this).val();
});
The final piece of data, percentDiscount should be retrieved using the data-uniqueid attribute. I'm not sure how to do this.
I want...
SomeItem[] items;
$.each($('.ItemPriceBox'), function () {
var uniqueid = $(this).data('uniqueid');
var finalPrice = $(this).val();
var percentDiscount = $('.ItemDiscountBox').where("uniqueid = " + uniqueid);
items[i] = new SomeItem(uniqueid,finalPrice,percentDiscount);
});
How can I solve this?