Forum Discussion

ysapiyev's avatar
ysapiyev
Responsive Resident
8 years ago

Trouble with adding checkbox

Hi everyone,

 

I wanted to add checkbox and tried this code:

svg.selectAll("foreignObject")
        .data(nodes)
        .enter().append("foreignObject")
        .attr('x' , o.x)
        .attr('y',  o.y)
        .attr('width', 50)
        .attr('height', 20)
        .append("xhtml:body")
        .html("<form><input type=checkbox id=check></input></form>")
     .on("click", function(d, i){            console.log(svg.select("#check").node().checked) 
            }) ;

How it can be added using "input"?

 

 

9 Replies

  • v-viig's avatar
    v-viig
    Community Champion

    Hi ysapiyev

     

    At first, you should include the second body tag since iframe already has it.

    The input tag can be added by using d3.append method.

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]

     

     

      • v-viig's avatar
        v-viig
        Community Champion

         

        You might use something like this code snippet:

         

        d3.select(Your_Root_Element)
            .append("input")
            .attr({
                type: "checkbox"
            });

         

        Ignat Vilesov,

        Software Engineer

         

        Microsoft Power BI Custom Visuals

        [email protected]