How to call a function on click of a checkbox which is a popup on click of d3 element like rect










2















I am having a rectangle which is d3 element, I want to click on that rect and a popup should come which will be having checkbox. On click of that checkbox a function should be called.

As of now when I call a function in the html, that particular function is not invoked



mini.append("g").selectAll("miniItems")
.data(data)
.enter().append("rect")
.attr("id", "rect")
.attr("x", 200)
.attr("y", function(d,i) return y2(i*1.2)+5;)
.attr("width", windowWidth - 700)
.attr("height", 15)
.attr("stroke", "grey")
.on("click", onClick);/*on click of d3 element this function is invoked*/

function onClick(d)
let content;
content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'></input>"+ "claim" + "</div>";
div.html(content)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY) + "px")
.style("display", "block");


function onClaim(value)/*this function is not executed*/
console.log(value);



enter image description here



I am not getting any solution in order to invoke that function

Any help is appreciated. Thank you in advance :)










share|improve this question




























    2















    I am having a rectangle which is d3 element, I want to click on that rect and a popup should come which will be having checkbox. On click of that checkbox a function should be called.

    As of now when I call a function in the html, that particular function is not invoked



    mini.append("g").selectAll("miniItems")
    .data(data)
    .enter().append("rect")
    .attr("id", "rect")
    .attr("x", 200)
    .attr("y", function(d,i) return y2(i*1.2)+5;)
    .attr("width", windowWidth - 700)
    .attr("height", 15)
    .attr("stroke", "grey")
    .on("click", onClick);/*on click of d3 element this function is invoked*/

    function onClick(d)
    let content;
    content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'></input>"+ "claim" + "</div>";
    div.html(content)
    .style("left", (d3.event.pageX) + "px")
    .style("top", (d3.event.pageY) + "px")
    .style("display", "block");


    function onClaim(value)/*this function is not executed*/
    console.log(value);



    enter image description here



    I am not getting any solution in order to invoke that function

    Any help is appreciated. Thank you in advance :)










    share|improve this question


























      2












      2








      2








      I am having a rectangle which is d3 element, I want to click on that rect and a popup should come which will be having checkbox. On click of that checkbox a function should be called.

      As of now when I call a function in the html, that particular function is not invoked



      mini.append("g").selectAll("miniItems")
      .data(data)
      .enter().append("rect")
      .attr("id", "rect")
      .attr("x", 200)
      .attr("y", function(d,i) return y2(i*1.2)+5;)
      .attr("width", windowWidth - 700)
      .attr("height", 15)
      .attr("stroke", "grey")
      .on("click", onClick);/*on click of d3 element this function is invoked*/

      function onClick(d)
      let content;
      content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'></input>"+ "claim" + "</div>";
      div.html(content)
      .style("left", (d3.event.pageX) + "px")
      .style("top", (d3.event.pageY) + "px")
      .style("display", "block");


      function onClaim(value)/*this function is not executed*/
      console.log(value);



      enter image description here



      I am not getting any solution in order to invoke that function

      Any help is appreciated. Thank you in advance :)










      share|improve this question
















      I am having a rectangle which is d3 element, I want to click on that rect and a popup should come which will be having checkbox. On click of that checkbox a function should be called.

      As of now when I call a function in the html, that particular function is not invoked



      mini.append("g").selectAll("miniItems")
      .data(data)
      .enter().append("rect")
      .attr("id", "rect")
      .attr("x", 200)
      .attr("y", function(d,i) return y2(i*1.2)+5;)
      .attr("width", windowWidth - 700)
      .attr("height", 15)
      .attr("stroke", "grey")
      .on("click", onClick);/*on click of d3 element this function is invoked*/

      function onClick(d)
      let content;
      content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'></input>"+ "claim" + "</div>";
      div.html(content)
      .style("left", (d3.event.pageX) + "px")
      .style("top", (d3.event.pageY) + "px")
      .style("display", "block");


      function onClaim(value)/*this function is not executed*/
      console.log(value);



      enter image description here



      I am not getting any solution in order to invoke that function

      Any help is appreciated. Thank you in advance :)







      javascript html angular d3.js






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 12:29







      Deeksha Mulgaonkar

















      asked Nov 14 '18 at 12:03









      Deeksha MulgaonkarDeeksha Mulgaonkar

      141111




      141111






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Why not add events the d3 way as you already are using d3?



          Within the onClick function, you can bind a click event to the input#myCheck.



          div.select('input#myCheck').on('click', function () 
          if(this.checked) // checking if the checkbox is checked
          onClaim(d.executionId);
          );


          And please post a working snippet which makes it easier to answer (as your post was missing definitions of div, mini etc. Anyway, I created a snippet using sample code here:






          var svg = d3.select('svg#chart');
          var div = d3.select('div.tooltip');

          var data = [id: 1, executionId: 1, id: 2, executionId: 2];

          svg.append("g").selectAll("miniItems")
          .data(data)
          .enter().append("rect")
          .attr("id", "rect")
          .attr("x", 100)
          .attr("y", function(d,i) return (i*100);)
          .attr("width", 100)
          .attr("height", 15)
          .style("stroke", "grey")
          .on("click", onClick);/*on click of d3 element this function is invoked*/

          function onClick(d)
          let content;
          content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck'/>"+ "claim" + "</div>";
          div.html(content)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY) + "px")
          .style("display", "block");
          div.select('input#myCheck').on('click', function ()
          if(this.checked)
          onClaim(d.executionId);
          )


          function onClaim(value)/*this function is not executed*/
          console.log(value);

          div.tooltip 
          position: absolute;

          <script src="https://d3js.org/d3.v4.min.js"></script>

          <svg id="chart" width="400" height="400"></svg>

          <div class="tooltip">

          </div>





          Hope this helps.






          share|improve this answer























          • Hi @Shashank thanks a lot for your reply :) It works now. Only thing is that "this.checked" is having some issue (in IDE it is underlined with red), this does not affect the output, but ng build fails due to this. I think this issue is because I am using typeScript. The message displayed on hovering on the "this.checked" is "Property 'checked' does not exist on type 'BaseType'. Property 'checked' does not exist on type 'Element". Any alternative way to check whether the checkbox is checked rather than using the above approach

            – Deeksha Mulgaonkar
            Nov 15 '18 at 10:18











          • Glad I could help! I'm not sure how typescript casts but I found this and think it might help: const input = this as HTMLInputElement; if(input.checked) onClaim(d.executionId); . It's basically getting the input element and checking it's checked property so I'm sure you can figure out how to get an HTML element's property in typescript.

            – Shashank
            Nov 15 '18 at 14:18



















          2














          You have some issues with quotes in your code. Try this:



           content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px;'>
          <input type='checkbox' onClick='onClaim(d.data);'>
          </div>"


          You were closing the surrounding " at the end of 30px;.
          I replaced that with a single quote and added a double quote at the very end.






          share|improve this answer























          • hi @sean Leroy, thanks for your reply :) but actually there was some mistake while posting the question with the quotes... So now I edited it and still its not working... Can you please point out where I have made mistake

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:19











          • Is there an error in your console or is it simply not executing with no indication why?

            – Sean Leroy
            Nov 14 '18 at 12:53











          • when I hover on that particular function onClaim , i get "'onClaim' is declared but its value is never read' " i get this message. So that means that particular function is not called at first place. I am not getting how to call it so that it can be executed.

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:57


















          1














          Hlo dkshaaa,



          you can try this.



          Since you are using checkbox instead of onClick you can use onChange.



          So instead of this



          <input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'>



          you can use



          <input type="checkbox" id="isCheckBox" (change)="onClaim($event, d.executionId)"/>



          and in angular component you can use the event as



          function onClaim(event, execId) 
          if(event.target.checked)
          //DO SOMETHING




          hope this helps. ;-)






          share|improve this answer























          • Hi DP, thanks for the reply but as I said that onClaim function is not invoked at all. When i hover on that function it is shown as ''onClaim' is declared but its value is never read' "...

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:48











          • @DeekshaMulgaonkar I think you have to create dynamic component for that pop-up. I'm not sure if any easier solution is there.

            – Durgaprasad Kusuma
            Nov 14 '18 at 14:01










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299818%2fhow-to-call-a-function-on-click-of-a-checkbox-which-is-a-popup-on-click-of-d3-el%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Why not add events the d3 way as you already are using d3?



          Within the onClick function, you can bind a click event to the input#myCheck.



          div.select('input#myCheck').on('click', function () 
          if(this.checked) // checking if the checkbox is checked
          onClaim(d.executionId);
          );


          And please post a working snippet which makes it easier to answer (as your post was missing definitions of div, mini etc. Anyway, I created a snippet using sample code here:






          var svg = d3.select('svg#chart');
          var div = d3.select('div.tooltip');

          var data = [id: 1, executionId: 1, id: 2, executionId: 2];

          svg.append("g").selectAll("miniItems")
          .data(data)
          .enter().append("rect")
          .attr("id", "rect")
          .attr("x", 100)
          .attr("y", function(d,i) return (i*100);)
          .attr("width", 100)
          .attr("height", 15)
          .style("stroke", "grey")
          .on("click", onClick);/*on click of d3 element this function is invoked*/

          function onClick(d)
          let content;
          content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck'/>"+ "claim" + "</div>";
          div.html(content)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY) + "px")
          .style("display", "block");
          div.select('input#myCheck').on('click', function ()
          if(this.checked)
          onClaim(d.executionId);
          )


          function onClaim(value)/*this function is not executed*/
          console.log(value);

          div.tooltip 
          position: absolute;

          <script src="https://d3js.org/d3.v4.min.js"></script>

          <svg id="chart" width="400" height="400"></svg>

          <div class="tooltip">

          </div>





          Hope this helps.






          share|improve this answer























          • Hi @Shashank thanks a lot for your reply :) It works now. Only thing is that "this.checked" is having some issue (in IDE it is underlined with red), this does not affect the output, but ng build fails due to this. I think this issue is because I am using typeScript. The message displayed on hovering on the "this.checked" is "Property 'checked' does not exist on type 'BaseType'. Property 'checked' does not exist on type 'Element". Any alternative way to check whether the checkbox is checked rather than using the above approach

            – Deeksha Mulgaonkar
            Nov 15 '18 at 10:18











          • Glad I could help! I'm not sure how typescript casts but I found this and think it might help: const input = this as HTMLInputElement; if(input.checked) onClaim(d.executionId); . It's basically getting the input element and checking it's checked property so I'm sure you can figure out how to get an HTML element's property in typescript.

            – Shashank
            Nov 15 '18 at 14:18
















          1














          Why not add events the d3 way as you already are using d3?



          Within the onClick function, you can bind a click event to the input#myCheck.



          div.select('input#myCheck').on('click', function () 
          if(this.checked) // checking if the checkbox is checked
          onClaim(d.executionId);
          );


          And please post a working snippet which makes it easier to answer (as your post was missing definitions of div, mini etc. Anyway, I created a snippet using sample code here:






          var svg = d3.select('svg#chart');
          var div = d3.select('div.tooltip');

          var data = [id: 1, executionId: 1, id: 2, executionId: 2];

          svg.append("g").selectAll("miniItems")
          .data(data)
          .enter().append("rect")
          .attr("id", "rect")
          .attr("x", 100)
          .attr("y", function(d,i) return (i*100);)
          .attr("width", 100)
          .attr("height", 15)
          .style("stroke", "grey")
          .on("click", onClick);/*on click of d3 element this function is invoked*/

          function onClick(d)
          let content;
          content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck'/>"+ "claim" + "</div>";
          div.html(content)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY) + "px")
          .style("display", "block");
          div.select('input#myCheck').on('click', function ()
          if(this.checked)
          onClaim(d.executionId);
          )


          function onClaim(value)/*this function is not executed*/
          console.log(value);

          div.tooltip 
          position: absolute;

          <script src="https://d3js.org/d3.v4.min.js"></script>

          <svg id="chart" width="400" height="400"></svg>

          <div class="tooltip">

          </div>





          Hope this helps.






          share|improve this answer























          • Hi @Shashank thanks a lot for your reply :) It works now. Only thing is that "this.checked" is having some issue (in IDE it is underlined with red), this does not affect the output, but ng build fails due to this. I think this issue is because I am using typeScript. The message displayed on hovering on the "this.checked" is "Property 'checked' does not exist on type 'BaseType'. Property 'checked' does not exist on type 'Element". Any alternative way to check whether the checkbox is checked rather than using the above approach

            – Deeksha Mulgaonkar
            Nov 15 '18 at 10:18











          • Glad I could help! I'm not sure how typescript casts but I found this and think it might help: const input = this as HTMLInputElement; if(input.checked) onClaim(d.executionId); . It's basically getting the input element and checking it's checked property so I'm sure you can figure out how to get an HTML element's property in typescript.

            – Shashank
            Nov 15 '18 at 14:18














          1












          1








          1







          Why not add events the d3 way as you already are using d3?



          Within the onClick function, you can bind a click event to the input#myCheck.



          div.select('input#myCheck').on('click', function () 
          if(this.checked) // checking if the checkbox is checked
          onClaim(d.executionId);
          );


          And please post a working snippet which makes it easier to answer (as your post was missing definitions of div, mini etc. Anyway, I created a snippet using sample code here:






          var svg = d3.select('svg#chart');
          var div = d3.select('div.tooltip');

          var data = [id: 1, executionId: 1, id: 2, executionId: 2];

          svg.append("g").selectAll("miniItems")
          .data(data)
          .enter().append("rect")
          .attr("id", "rect")
          .attr("x", 100)
          .attr("y", function(d,i) return (i*100);)
          .attr("width", 100)
          .attr("height", 15)
          .style("stroke", "grey")
          .on("click", onClick);/*on click of d3 element this function is invoked*/

          function onClick(d)
          let content;
          content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck'/>"+ "claim" + "</div>";
          div.html(content)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY) + "px")
          .style("display", "block");
          div.select('input#myCheck').on('click', function ()
          if(this.checked)
          onClaim(d.executionId);
          )


          function onClaim(value)/*this function is not executed*/
          console.log(value);

          div.tooltip 
          position: absolute;

          <script src="https://d3js.org/d3.v4.min.js"></script>

          <svg id="chart" width="400" height="400"></svg>

          <div class="tooltip">

          </div>





          Hope this helps.






          share|improve this answer













          Why not add events the d3 way as you already are using d3?



          Within the onClick function, you can bind a click event to the input#myCheck.



          div.select('input#myCheck').on('click', function () 
          if(this.checked) // checking if the checkbox is checked
          onClaim(d.executionId);
          );


          And please post a working snippet which makes it easier to answer (as your post was missing definitions of div, mini etc. Anyway, I created a snippet using sample code here:






          var svg = d3.select('svg#chart');
          var div = d3.select('div.tooltip');

          var data = [id: 1, executionId: 1, id: 2, executionId: 2];

          svg.append("g").selectAll("miniItems")
          .data(data)
          .enter().append("rect")
          .attr("id", "rect")
          .attr("x", 100)
          .attr("y", function(d,i) return (i*100);)
          .attr("width", 100)
          .attr("height", 15)
          .style("stroke", "grey")
          .on("click", onClick);/*on click of d3 element this function is invoked*/

          function onClick(d)
          let content;
          content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck'/>"+ "claim" + "</div>";
          div.html(content)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY) + "px")
          .style("display", "block");
          div.select('input#myCheck').on('click', function ()
          if(this.checked)
          onClaim(d.executionId);
          )


          function onClaim(value)/*this function is not executed*/
          console.log(value);

          div.tooltip 
          position: absolute;

          <script src="https://d3js.org/d3.v4.min.js"></script>

          <svg id="chart" width="400" height="400"></svg>

          <div class="tooltip">

          </div>





          Hope this helps.






          var svg = d3.select('svg#chart');
          var div = d3.select('div.tooltip');

          var data = [id: 1, executionId: 1, id: 2, executionId: 2];

          svg.append("g").selectAll("miniItems")
          .data(data)
          .enter().append("rect")
          .attr("id", "rect")
          .attr("x", 100)
          .attr("y", function(d,i) return (i*100);)
          .attr("width", 100)
          .attr("height", 15)
          .style("stroke", "grey")
          .on("click", onClick);/*on click of d3 element this function is invoked*/

          function onClick(d)
          let content;
          content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck'/>"+ "claim" + "</div>";
          div.html(content)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY) + "px")
          .style("display", "block");
          div.select('input#myCheck').on('click', function ()
          if(this.checked)
          onClaim(d.executionId);
          )


          function onClaim(value)/*this function is not executed*/
          console.log(value);

          div.tooltip 
          position: absolute;

          <script src="https://d3js.org/d3.v4.min.js"></script>

          <svg id="chart" width="400" height="400"></svg>

          <div class="tooltip">

          </div>





          var svg = d3.select('svg#chart');
          var div = d3.select('div.tooltip');

          var data = [id: 1, executionId: 1, id: 2, executionId: 2];

          svg.append("g").selectAll("miniItems")
          .data(data)
          .enter().append("rect")
          .attr("id", "rect")
          .attr("x", 100)
          .attr("y", function(d,i) return (i*100);)
          .attr("width", 100)
          .attr("height", 15)
          .style("stroke", "grey")
          .on("click", onClick);/*on click of d3 element this function is invoked*/

          function onClick(d)
          let content;
          content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px; padding:8%'><input type='checkbox' id='myCheck'/>"+ "claim" + "</div>";
          div.html(content)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY) + "px")
          .style("display", "block");
          div.select('input#myCheck').on('click', function ()
          if(this.checked)
          onClaim(d.executionId);
          )


          function onClaim(value)/*this function is not executed*/
          console.log(value);

          div.tooltip 
          position: absolute;

          <script src="https://d3js.org/d3.v4.min.js"></script>

          <svg id="chart" width="400" height="400"></svg>

          <div class="tooltip">

          </div>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 18:21









          ShashankShashank

          4,6251512




          4,6251512












          • Hi @Shashank thanks a lot for your reply :) It works now. Only thing is that "this.checked" is having some issue (in IDE it is underlined with red), this does not affect the output, but ng build fails due to this. I think this issue is because I am using typeScript. The message displayed on hovering on the "this.checked" is "Property 'checked' does not exist on type 'BaseType'. Property 'checked' does not exist on type 'Element". Any alternative way to check whether the checkbox is checked rather than using the above approach

            – Deeksha Mulgaonkar
            Nov 15 '18 at 10:18











          • Glad I could help! I'm not sure how typescript casts but I found this and think it might help: const input = this as HTMLInputElement; if(input.checked) onClaim(d.executionId); . It's basically getting the input element and checking it's checked property so I'm sure you can figure out how to get an HTML element's property in typescript.

            – Shashank
            Nov 15 '18 at 14:18


















          • Hi @Shashank thanks a lot for your reply :) It works now. Only thing is that "this.checked" is having some issue (in IDE it is underlined with red), this does not affect the output, but ng build fails due to this. I think this issue is because I am using typeScript. The message displayed on hovering on the "this.checked" is "Property 'checked' does not exist on type 'BaseType'. Property 'checked' does not exist on type 'Element". Any alternative way to check whether the checkbox is checked rather than using the above approach

            – Deeksha Mulgaonkar
            Nov 15 '18 at 10:18











          • Glad I could help! I'm not sure how typescript casts but I found this and think it might help: const input = this as HTMLInputElement; if(input.checked) onClaim(d.executionId); . It's basically getting the input element and checking it's checked property so I'm sure you can figure out how to get an HTML element's property in typescript.

            – Shashank
            Nov 15 '18 at 14:18

















          Hi @Shashank thanks a lot for your reply :) It works now. Only thing is that "this.checked" is having some issue (in IDE it is underlined with red), this does not affect the output, but ng build fails due to this. I think this issue is because I am using typeScript. The message displayed on hovering on the "this.checked" is "Property 'checked' does not exist on type 'BaseType'. Property 'checked' does not exist on type 'Element". Any alternative way to check whether the checkbox is checked rather than using the above approach

          – Deeksha Mulgaonkar
          Nov 15 '18 at 10:18





          Hi @Shashank thanks a lot for your reply :) It works now. Only thing is that "this.checked" is having some issue (in IDE it is underlined with red), this does not affect the output, but ng build fails due to this. I think this issue is because I am using typeScript. The message displayed on hovering on the "this.checked" is "Property 'checked' does not exist on type 'BaseType'. Property 'checked' does not exist on type 'Element". Any alternative way to check whether the checkbox is checked rather than using the above approach

          – Deeksha Mulgaonkar
          Nov 15 '18 at 10:18













          Glad I could help! I'm not sure how typescript casts but I found this and think it might help: const input = this as HTMLInputElement; if(input.checked) onClaim(d.executionId); . It's basically getting the input element and checking it's checked property so I'm sure you can figure out how to get an HTML element's property in typescript.

          – Shashank
          Nov 15 '18 at 14:18






          Glad I could help! I'm not sure how typescript casts but I found this and think it might help: const input = this as HTMLInputElement; if(input.checked) onClaim(d.executionId); . It's basically getting the input element and checking it's checked property so I'm sure you can figure out how to get an HTML element's property in typescript.

          – Shashank
          Nov 15 '18 at 14:18














          2














          You have some issues with quotes in your code. Try this:



           content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px;'>
          <input type='checkbox' onClick='onClaim(d.data);'>
          </div>"


          You were closing the surrounding " at the end of 30px;.
          I replaced that with a single quote and added a double quote at the very end.






          share|improve this answer























          • hi @sean Leroy, thanks for your reply :) but actually there was some mistake while posting the question with the quotes... So now I edited it and still its not working... Can you please point out where I have made mistake

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:19











          • Is there an error in your console or is it simply not executing with no indication why?

            – Sean Leroy
            Nov 14 '18 at 12:53











          • when I hover on that particular function onClaim , i get "'onClaim' is declared but its value is never read' " i get this message. So that means that particular function is not called at first place. I am not getting how to call it so that it can be executed.

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:57















          2














          You have some issues with quotes in your code. Try this:



           content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px;'>
          <input type='checkbox' onClick='onClaim(d.data);'>
          </div>"


          You were closing the surrounding " at the end of 30px;.
          I replaced that with a single quote and added a double quote at the very end.






          share|improve this answer























          • hi @sean Leroy, thanks for your reply :) but actually there was some mistake while posting the question with the quotes... So now I edited it and still its not working... Can you please point out where I have made mistake

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:19











          • Is there an error in your console or is it simply not executing with no indication why?

            – Sean Leroy
            Nov 14 '18 at 12:53











          • when I hover on that particular function onClaim , i get "'onClaim' is declared but its value is never read' " i get this message. So that means that particular function is not called at first place. I am not getting how to call it so that it can be executed.

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:57













          2












          2








          2







          You have some issues with quotes in your code. Try this:



           content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px;'>
          <input type='checkbox' onClick='onClaim(d.data);'>
          </div>"


          You were closing the surrounding " at the end of 30px;.
          I replaced that with a single quote and added a double quote at the very end.






          share|improve this answer













          You have some issues with quotes in your code. Try this:



           content = "<div style='background: white;width:70px; box-shadow:3px 3px 5px #797878;height:30px;'>
          <input type='checkbox' onClick='onClaim(d.data);'>
          </div>"


          You were closing the surrounding " at the end of 30px;.
          I replaced that with a single quote and added a double quote at the very end.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 12:09









          Sean LeroySean Leroy

          687




          687












          • hi @sean Leroy, thanks for your reply :) but actually there was some mistake while posting the question with the quotes... So now I edited it and still its not working... Can you please point out where I have made mistake

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:19











          • Is there an error in your console or is it simply not executing with no indication why?

            – Sean Leroy
            Nov 14 '18 at 12:53











          • when I hover on that particular function onClaim , i get "'onClaim' is declared but its value is never read' " i get this message. So that means that particular function is not called at first place. I am not getting how to call it so that it can be executed.

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:57

















          • hi @sean Leroy, thanks for your reply :) but actually there was some mistake while posting the question with the quotes... So now I edited it and still its not working... Can you please point out where I have made mistake

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:19











          • Is there an error in your console or is it simply not executing with no indication why?

            – Sean Leroy
            Nov 14 '18 at 12:53











          • when I hover on that particular function onClaim , i get "'onClaim' is declared but its value is never read' " i get this message. So that means that particular function is not called at first place. I am not getting how to call it so that it can be executed.

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:57
















          hi @sean Leroy, thanks for your reply :) but actually there was some mistake while posting the question with the quotes... So now I edited it and still its not working... Can you please point out where I have made mistake

          – Deeksha Mulgaonkar
          Nov 14 '18 at 12:19





          hi @sean Leroy, thanks for your reply :) but actually there was some mistake while posting the question with the quotes... So now I edited it and still its not working... Can you please point out where I have made mistake

          – Deeksha Mulgaonkar
          Nov 14 '18 at 12:19













          Is there an error in your console or is it simply not executing with no indication why?

          – Sean Leroy
          Nov 14 '18 at 12:53





          Is there an error in your console or is it simply not executing with no indication why?

          – Sean Leroy
          Nov 14 '18 at 12:53













          when I hover on that particular function onClaim , i get "'onClaim' is declared but its value is never read' " i get this message. So that means that particular function is not called at first place. I am not getting how to call it so that it can be executed.

          – Deeksha Mulgaonkar
          Nov 14 '18 at 12:57





          when I hover on that particular function onClaim , i get "'onClaim' is declared but its value is never read' " i get this message. So that means that particular function is not called at first place. I am not getting how to call it so that it can be executed.

          – Deeksha Mulgaonkar
          Nov 14 '18 at 12:57











          1














          Hlo dkshaaa,



          you can try this.



          Since you are using checkbox instead of onClick you can use onChange.



          So instead of this



          <input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'>



          you can use



          <input type="checkbox" id="isCheckBox" (change)="onClaim($event, d.executionId)"/>



          and in angular component you can use the event as



          function onClaim(event, execId) 
          if(event.target.checked)
          //DO SOMETHING




          hope this helps. ;-)






          share|improve this answer























          • Hi DP, thanks for the reply but as I said that onClaim function is not invoked at all. When i hover on that function it is shown as ''onClaim' is declared but its value is never read' "...

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:48











          • @DeekshaMulgaonkar I think you have to create dynamic component for that pop-up. I'm not sure if any easier solution is there.

            – Durgaprasad Kusuma
            Nov 14 '18 at 14:01















          1














          Hlo dkshaaa,



          you can try this.



          Since you are using checkbox instead of onClick you can use onChange.



          So instead of this



          <input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'>



          you can use



          <input type="checkbox" id="isCheckBox" (change)="onClaim($event, d.executionId)"/>



          and in angular component you can use the event as



          function onClaim(event, execId) 
          if(event.target.checked)
          //DO SOMETHING




          hope this helps. ;-)






          share|improve this answer























          • Hi DP, thanks for the reply but as I said that onClaim function is not invoked at all. When i hover on that function it is shown as ''onClaim' is declared but its value is never read' "...

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:48











          • @DeekshaMulgaonkar I think you have to create dynamic component for that pop-up. I'm not sure if any easier solution is there.

            – Durgaprasad Kusuma
            Nov 14 '18 at 14:01













          1












          1








          1







          Hlo dkshaaa,



          you can try this.



          Since you are using checkbox instead of onClick you can use onChange.



          So instead of this



          <input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'>



          you can use



          <input type="checkbox" id="isCheckBox" (change)="onClaim($event, d.executionId)"/>



          and in angular component you can use the event as



          function onClaim(event, execId) 
          if(event.target.checked)
          //DO SOMETHING




          hope this helps. ;-)






          share|improve this answer













          Hlo dkshaaa,



          you can try this.



          Since you are using checkbox instead of onClick you can use onChange.



          So instead of this



          <input type='checkbox' id='myCheck' (click)='onClaim(d.executionId)'>



          you can use



          <input type="checkbox" id="isCheckBox" (change)="onClaim($event, d.executionId)"/>



          and in angular component you can use the event as



          function onClaim(event, execId) 
          if(event.target.checked)
          //DO SOMETHING




          hope this helps. ;-)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 12:39









          Durgaprasad KusumaDurgaprasad Kusuma

          72110




          72110












          • Hi DP, thanks for the reply but as I said that onClaim function is not invoked at all. When i hover on that function it is shown as ''onClaim' is declared but its value is never read' "...

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:48











          • @DeekshaMulgaonkar I think you have to create dynamic component for that pop-up. I'm not sure if any easier solution is there.

            – Durgaprasad Kusuma
            Nov 14 '18 at 14:01

















          • Hi DP, thanks for the reply but as I said that onClaim function is not invoked at all. When i hover on that function it is shown as ''onClaim' is declared but its value is never read' "...

            – Deeksha Mulgaonkar
            Nov 14 '18 at 12:48











          • @DeekshaMulgaonkar I think you have to create dynamic component for that pop-up. I'm not sure if any easier solution is there.

            – Durgaprasad Kusuma
            Nov 14 '18 at 14:01
















          Hi DP, thanks for the reply but as I said that onClaim function is not invoked at all. When i hover on that function it is shown as ''onClaim' is declared but its value is never read' "...

          – Deeksha Mulgaonkar
          Nov 14 '18 at 12:48





          Hi DP, thanks for the reply but as I said that onClaim function is not invoked at all. When i hover on that function it is shown as ''onClaim' is declared but its value is never read' "...

          – Deeksha Mulgaonkar
          Nov 14 '18 at 12:48













          @DeekshaMulgaonkar I think you have to create dynamic component for that pop-up. I'm not sure if any easier solution is there.

          – Durgaprasad Kusuma
          Nov 14 '18 at 14:01





          @DeekshaMulgaonkar I think you have to create dynamic component for that pop-up. I'm not sure if any easier solution is there.

          – Durgaprasad Kusuma
          Nov 14 '18 at 14:01

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299818%2fhow-to-call-a-function-on-click-of-a-checkbox-which-is-a-popup-on-click-of-d3-el%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          政党

          天津地下鉄3号線