jquery.repeater icon indicating copy to clipboard operation
jquery.repeater copied to clipboard

Jquery callback for input fields

Open ladaposamuel opened this issue 1 year ago • 4 comments

I created a set of input fields that accepts numbers and planned to sum the inputted numbers somewhere, but jquery callback doesn't work with newly duplicated items.


   <div class="col-lg-3 col-12 my-lg-0 my-2">
                                                    <p class="card-text col-title mb-md-2 mb-0">DR</p>
                                                    <input type="text" class="form-control dr" name="DR"
                                                           placeholder=""/>
                                                </div>
                                                <div class="col-lg-3 col-12 my-lg-0 my-2">
                                                    <p class="card-text col-title mb-md-2 mb-0">CR</p>
                                                    <input type="text" class="form-control cr" name="CR"
                                                           placeholder="" />
                                                </div>
   $('.cr').blur(function () {
        var sum = 0;
        $('.cr').each(function () {
            sum += Number($(this).val());
        });
        $('.total-cr').html(Intl.NumberFormat('en-US', {}).format(sum))
    });
 $('.dr').blur(function () {
        var sum = 0;
        $('.dr').each(function () {
            sum += Number($(this).val());
        });

        $('.total-dr').html(Intl.NumberFormat('en-US', {}).format(sum))
    });

Screenshot 2023-04-08 at 10 24 36 AM

ladaposamuel avatar Apr 08 '23 09:04 ladaposamuel

@ladaposamuel any chance you got this working?

pkh1979 avatar May 05 '24 13:05 pkh1979

@ladaposamuel any chance you got this working?

Decided to go a different route using vuejs

sirproton avatar May 05 '24 14:05 sirproton

Oh alright. Anyways, I figured out a way to handle this.

All you have to do is add a event listener in the repeater show function.

pkh1979 avatar May 05 '24 15:05 pkh1979

Oh alright. Anyways, I figured out a way to handle this.

All you have to do is add a event listener in the repeater show function.

Can you put a snippet here for any future person that stumbles on this issue too. :)

sirproton avatar May 05 '24 15:05 sirproton