Giter VIP home page Giter VIP logo

Comments (5)

patrick-steele-idem avatar patrick-steele-idem commented on June 16, 2024

Good question. This has come up before and we made some code changes to support this use case. The problem is that the server is not keeping any state and the unique IDs reset back to 0 reset for each request. As a workaround, we allow the application code to provide a "widget ID prefix" which is just some string that is prefixed to the auto generated ID and this prefix can be used to keep widget IDs unique across requests (assuming the application code provides an appropriate prefix).

The widget ID prefix should be provided as part of the rendering "global" object as shown in the following sample code:

template.render({
        $global: {
            widgetIdPrefix: 'w' + Math.random()
        }
    },
    function(err, html) {

    });

Here is the related code that is used to generate unique IDs on the server: lib/uniqueId.js

Does that solve your problem?

from marko-widgets.

peterdotjs avatar peterdotjs commented on June 16, 2024

Yeah that should work. We'll give it a try.

Correcting the link you listed:
https://github.com/raptorjs/marko-widgets/blob/master/lib/uniqueId.js

from marko-widgets.

patrick-steele-idem avatar patrick-steele-idem commented on June 16, 2024

Please update this Github issue when verified.

I have updated the link. Thanks.

from marko-widgets.

patrick-steele-idem avatar patrick-steele-idem commented on June 16, 2024

ping. Did this solution work for you?

from marko-widgets.

peterdotjs avatar peterdotjs commented on June 16, 2024

Sorry, I didn't close this sooner. The suggested fix works great.

from marko-widgets.

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.