Giter Club home page Giter Club logo

Comments (3)

BorisMoore avatar BorisMoore commented on July 18, 2024

In your scenario you are wanting to data-link the innerHTML of a <select> - which is a different 'target' than the default value. See this section for discussion of multiple targets: Full syntax – multiple targets, multiple tags, multiple bindings...

So you need to use the target html{...}, for innerHTML . You can at the same time bind to value property, which is the default target for a <select> element. So you will have something like:

<select data-link="html{for selectOptions tmpl='nameTmpl'} {:chosenOption:}"></select>

using the data:

var appData = {
    chosenOption:"Option 2",
    selectOptions: [{ option: "Option 1" }, { option: "Option 2" }],
};

Here is an updated version of your JsFiddle: https://jsfiddle.net/BorisMoore/g26dzp4a/2/

See also Data-linking to innerText / innerHTML
as well as the related sample using the jQueryUI {{selectMenu}} control (second sample in the page)

from jsviews.

alnico2001 avatar alnico2001 commented on July 18, 2024

Ah yes, I should have caught that...1st time doing top-level data linking.
Thanks Boris!

from jsviews.

BorisMoore avatar BorisMoore commented on July 18, 2024

BTW, the same syntax for multiple targets, and the html{} target for <select> apply equally to regular linked template binding, as well as top-level binding.

see: https://jsfiddle.net/BorisMoore/vjz8f5h0/

Closing as "question" (not a bug)

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.