Skip to content

Instantly share code, notes, and snippets.

@1990prashant
Created March 16, 2016 06:23

Revisions

  1. Prashant Kumar Mishra created this gist Mar 16, 2016.
    21 changes: 21 additions & 0 deletions application.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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();
    });