Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jquery callback for input fields #174

Open
ladaposamuel opened this issue Apr 8, 2023 · 4 comments
Open

Jquery callback for input fields #174

ladaposamuel opened this issue Apr 8, 2023 · 4 comments

Comments

@ladaposamuel
Copy link

ladaposamuel commented Apr 8, 2023

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

@pkh1979
Copy link

pkh1979 commented May 5, 2024

@ladaposamuel any chance you got this working?

@sirproton
Copy link

@ladaposamuel any chance you got this working?

Decided to go a different route using vuejs

@pkh1979
Copy link

pkh1979 commented May 5, 2024

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.

@sirproton
Copy link

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants