Giter VIP home page Giter VIP logo

Comments (7)

arguiot avatar arguiot commented on May 18, 2024

I see πŸ€”, don’t worry πŸ˜‰, I’ll try to fix that for you as soon as possible. The $.live() function will always have some bugs because I’m trying to implement non-standards functions (in this case, Object.prototype.watch()). I’m nearly sure that the problem comes from the function itself.

In the next week, I’ll try to fix every function to deliver the v1.0.0 of DisplayJS as soon as possible.

Thank you πŸ™ for submitting this issue 😊.

from displayjs.

arguiot avatar arguiot commented on May 18, 2024

Just to make sure, why are you using self in the Λ‹$.live()Λ‹ function? I think πŸ€” there is an issue here, because the Λ‹selfΛ‹ object is not ment to be use here 😊.

from displayjs.

arguiot avatar arguiot commented on May 18, 2024

For the moment, you can use:

var cart = {
  amount: 0.0,
  charge: 0.0
};

var $djs = new DisplayJS(cart);
$djs.var();
$djs.target(function () {
  var charge = calcCharge(parseInt(cart.amount));
  cart["charge"] = charge;
   $djs.var()
});

function calcCharge(goal) {
  var stripeFixed = 0.3;
  var stripePercent = 0.029;
  var numerator = goal + stripeFixed;
  var denominator = 1.0 - stripePercent;
  var charge = numerator / denominator;
  return charge;
}

from displayjs.

guyjacks avatar guyjacks commented on May 18, 2024

I didn't mean to leave the "self" in there. I was trying something else and forgot to remove it. It's gone now.

from displayjs.

arguiot avatar arguiot commented on May 18, 2024

@guyjacks Also, the $.live() is not a function that should be used often, especially in small projects. DisplayJS have a lot of way to dynamically update values. So, I simply used a callback in the $.target() function to update everything 😊

from displayjs.

guyjacks avatar guyjacks commented on May 18, 2024

I just got it working with the code you shared above. Thank you.

from displayjs.

arguiot avatar arguiot commented on May 18, 2024

The problem was that you triggered 2 things in the exact moment (which is technically impossible in JavaScript, but because I'm dealing with low-level APIs, there is bugs), but because JavaScript is a working on single core, your browser that simply doesn't want to crash skip this step 😊

from displayjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.