Code Monkey home page Code Monkey logo

Comments (3)

gavinballard avatar gavinballard commented on September 13, 2024

Taking a quick look at your demo site, it looks like your whole <body> element is set up as a Rivets view, then the shipping estimator is a "sub-view". I don't think Rivets supports binding nested views like that, which could be causing your problem. I'd try splitting out the views into smaller containers (you can have multiple data-cart-view elements on a page) and making sure the custom Rivets view you're setting up isn't contained within them.

Alternatively, you can pass custom data models for use with Rivets.js when you initialise CartJS using the rivetsModels option. You could declare a shippingEstimator object, pass that to CartJS in rivetsModels, then update that model with your own code and the re-renders should work as expected.

from cartjs.

bakura10 avatar bakura10 commented on September 13, 2024

Hi,

That sounds interesting. I'll need to know how I can update the models within code and I'll let you know ;).

from cartjs.

gavinballard avatar gavinballard commented on September 13, 2024

Simplified, something like this:

<script>
  $(function() {
    var customer  = {{ customer | json }};

    CartJS.init({{ cart | json }}, {
      rivetsModels: {
        "customer": customer
      }
    });

    // Update customer variable here and any bound views will update.
    $('#updateEmailButton').click(function() {
      customer.email = $('#updateEmailInput').val();
    });
  });
</script>

from cartjs.

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.