Giter Club home page Giter Club logo

Comments (6)

BorisMoore avatar BorisMoore commented on August 17, 2024

Thank you very much for posting this. It's a good catch. I'll need to do some investigation... I'll let you know...

from jsviews.

BorisMoore avatar BorisMoore commented on August 17, 2024

Here is a potential update that should address your issues. Can you test that it works correctly for you?

jsviews.zip

Incidentally, your example is data-linking to util1(), as if it was a computed observable, but for the binding to work, it needs an associated setter function. See https://www.jsviews.com/#computed@getset.

For example, you could write:

let tmpl = $.templates("{^{tag1 Prop1() param1=~hlp.util1(1) /}}");
let utils = {hlp: {
    util1: function(a) {
      return this._util1;
    },
  _util1: "initUtil1"
}};
utils.hlp.util1.set = function(val) {
  this._util1 = val;
};
tmpl.link("#text1", m, utils); 

If you provide a setter, as above, the "view.ctxPrm(...) is not a function" exception will not be thrown.

But with the jsviews.js update provided there will no longer be any exception, even if you don't provide a setter. (Though of course two-way binding will not work unless there is a setter defined...)

Let me know if this works for you...

from jsviews.

AlexxVS avatar AlexxVS commented on August 17, 2024

Thank you, Boris. The update resolves both throwing the exception and double onBind event.

from jsviews.

BorisMoore avatar BorisMoore commented on August 17, 2024

Thanks for confirming. I except to include this in the upcoming version 1.0.10.

from jsviews.

BorisMoore avatar BorisMoore commented on August 17, 2024

The fix concerns two issues:

  • Binding to a computed function with no getter, such as <input data-link="name()"/> with name.set undefined leads to an exception "name is not a function".
  • Tag two-way binding to a computed observable, such as {^{mytag name()/}} can trigger onBind callback twice.

from jsviews.

BorisMoore avatar BorisMoore commented on August 17, 2024

Fixed in release v1.0.10

from jsviews.

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.