Skip to content

Instantly share code, notes, and snippets.

@1990prashant
Created March 16, 2016 06:23
Show Gist options
  • Save 1990prashant/1633a7abf238472e1edb to your computer and use it in GitHub Desktop.
Save 1990prashant/1633a7abf238472e1edb to your computer and use it in GitHub Desktop.
To write prototype js
var mashkar = {
init: function() {
this.calculateTotalPrice();
},
calculateTotalPrice: function() {
$(document).on("change", '.price-field', function() {
var variantRow = $(this).closest(".variant-row");
var sellerPrice = parseFloat($(this).val());
var basePrice = parseFloat(variantRow.find(".base-price").data("base_price"));
variantRow.find(".final-price").text((sellerPrice + basePrice).toFixed(2))
});
}
};
$(document).ready(function() {
mashkar.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment