How to access data in the modal from button click?












0















{individual && individual.map((el)=>{
return (
<a href="#" data-toggle="modal" data-target="#responsive-modal" className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</a>
<div id="responsive-modal" className="modal fade emp-add-list" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style={{display: "none"}}>
<div className="modal-dialog">
<div className="modal-content">

<div className="modal-body">
<div className="form-group">
<div className="checkbox">
<button type="button" className="btn btn-danger" onClick={this.withdrawPlan.bind(this, el)}>Withdraw Plan</button>
</div>
</div>
</div>
</div>
</div>
</div>

)
})
}





withdrawPlan(el){
let data = {
subscription_plan_id: 'SP5bd18b12b144f81f341a72ed',
reason: this.state.withdrawl_reason
}
UserAction._planWithdrawl(data);
}


I am having a button to unsubscribe from unsubscribe i can get all the el data, how to access that el data in the modal, on click of withdrawplan I need to access the el data.










share|improve this question





























    0















    {individual && individual.map((el)=>{
    return (
    <a href="#" data-toggle="modal" data-target="#responsive-modal" className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</a>
    <div id="responsive-modal" className="modal fade emp-add-list" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style={{display: "none"}}>
    <div className="modal-dialog">
    <div className="modal-content">

    <div className="modal-body">
    <div className="form-group">
    <div className="checkbox">
    <button type="button" className="btn btn-danger" onClick={this.withdrawPlan.bind(this, el)}>Withdraw Plan</button>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>

    )
    })
    }





    withdrawPlan(el){
    let data = {
    subscription_plan_id: 'SP5bd18b12b144f81f341a72ed',
    reason: this.state.withdrawl_reason
    }
    UserAction._planWithdrawl(data);
    }


    I am having a button to unsubscribe from unsubscribe i can get all the el data, how to access that el data in the modal, on click of withdrawplan I need to access the el data.










    share|improve this question



























      0












      0








      0








      {individual && individual.map((el)=>{
      return (
      <a href="#" data-toggle="modal" data-target="#responsive-modal" className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</a>
      <div id="responsive-modal" className="modal fade emp-add-list" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style={{display: "none"}}>
      <div className="modal-dialog">
      <div className="modal-content">

      <div className="modal-body">
      <div className="form-group">
      <div className="checkbox">
      <button type="button" className="btn btn-danger" onClick={this.withdrawPlan.bind(this, el)}>Withdraw Plan</button>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>

      )
      })
      }





      withdrawPlan(el){
      let data = {
      subscription_plan_id: 'SP5bd18b12b144f81f341a72ed',
      reason: this.state.withdrawl_reason
      }
      UserAction._planWithdrawl(data);
      }


      I am having a button to unsubscribe from unsubscribe i can get all the el data, how to access that el data in the modal, on click of withdrawplan I need to access the el data.










      share|improve this question
















      {individual && individual.map((el)=>{
      return (
      <a href="#" data-toggle="modal" data-target="#responsive-modal" className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</a>
      <div id="responsive-modal" className="modal fade emp-add-list" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style={{display: "none"}}>
      <div className="modal-dialog">
      <div className="modal-content">

      <div className="modal-body">
      <div className="form-group">
      <div className="checkbox">
      <button type="button" className="btn btn-danger" onClick={this.withdrawPlan.bind(this, el)}>Withdraw Plan</button>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>

      )
      })
      }





      withdrawPlan(el){
      let data = {
      subscription_plan_id: 'SP5bd18b12b144f81f341a72ed',
      reason: this.state.withdrawl_reason
      }
      UserAction._planWithdrawl(data);
      }


      I am having a button to unsubscribe from unsubscribe i can get all the el data, how to access that el data in the modal, on click of withdrawplan I need to access the el data.







      javascript reactjs bootstrap-modal






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 5:44







      sivasai081

















      asked Nov 14 '18 at 3:40









      sivasai081sivasai081

      237




      237
























          1 Answer
          1






          active

          oldest

          votes


















          0














          If i am understanding it correctly.
          Firstly why are you having method in template?



          You dont need anchor tag. you can have data in modal via function



          <button href="#" data-toggle="modal" data-target="#responsive-modal" onClick={()=>this.myFunction(el)} className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</button>


          In my function save the data in state and trigger the modal from there. Your state should be like



          this.state = {
          enableModal: false,
          data: null
          }






          share|improve this answer


























          • what is myFunction, IN that what will be there

            – sivasai081
            Nov 14 '18 at 5:01













          • IN my function i can access el but in the modal we are having button , from that button how to access that el

            – sivasai081
            Nov 14 '18 at 5:03











          • Thats because your modal is outside of individual.map function. You have to keep it inside the loop just like unsubscribe.

            – shez
            Nov 14 '18 at 5:09











          • @sivasai081 have you tried <button type="button" className="btn btn-danger" onClick={()=>this.withdrawPlan(el)}>Withdraw Plan</button> You need to bind withdrawPlan in constructor this.his.withdrawPlan = this.his.withdrawPlan.bind(this)

            – shez
            Nov 14 '18 at 6:04











          • yes i already binded

            – sivasai081
            Nov 14 '18 at 6:26











          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%2f53292867%2fhow-to-access-data-in-the-modal-from-button-click%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          If i am understanding it correctly.
          Firstly why are you having method in template?



          You dont need anchor tag. you can have data in modal via function



          <button href="#" data-toggle="modal" data-target="#responsive-modal" onClick={()=>this.myFunction(el)} className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</button>


          In my function save the data in state and trigger the modal from there. Your state should be like



          this.state = {
          enableModal: false,
          data: null
          }






          share|improve this answer


























          • what is myFunction, IN that what will be there

            – sivasai081
            Nov 14 '18 at 5:01













          • IN my function i can access el but in the modal we are having button , from that button how to access that el

            – sivasai081
            Nov 14 '18 at 5:03











          • Thats because your modal is outside of individual.map function. You have to keep it inside the loop just like unsubscribe.

            – shez
            Nov 14 '18 at 5:09











          • @sivasai081 have you tried <button type="button" className="btn btn-danger" onClick={()=>this.withdrawPlan(el)}>Withdraw Plan</button> You need to bind withdrawPlan in constructor this.his.withdrawPlan = this.his.withdrawPlan.bind(this)

            – shez
            Nov 14 '18 at 6:04











          • yes i already binded

            – sivasai081
            Nov 14 '18 at 6:26
















          0














          If i am understanding it correctly.
          Firstly why are you having method in template?



          You dont need anchor tag. you can have data in modal via function



          <button href="#" data-toggle="modal" data-target="#responsive-modal" onClick={()=>this.myFunction(el)} className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</button>


          In my function save the data in state and trigger the modal from there. Your state should be like



          this.state = {
          enableModal: false,
          data: null
          }






          share|improve this answer


























          • what is myFunction, IN that what will be there

            – sivasai081
            Nov 14 '18 at 5:01













          • IN my function i can access el but in the modal we are having button , from that button how to access that el

            – sivasai081
            Nov 14 '18 at 5:03











          • Thats because your modal is outside of individual.map function. You have to keep it inside the loop just like unsubscribe.

            – shez
            Nov 14 '18 at 5:09











          • @sivasai081 have you tried <button type="button" className="btn btn-danger" onClick={()=>this.withdrawPlan(el)}>Withdraw Plan</button> You need to bind withdrawPlan in constructor this.his.withdrawPlan = this.his.withdrawPlan.bind(this)

            – shez
            Nov 14 '18 at 6:04











          • yes i already binded

            – sivasai081
            Nov 14 '18 at 6:26














          0












          0








          0







          If i am understanding it correctly.
          Firstly why are you having method in template?



          You dont need anchor tag. you can have data in modal via function



          <button href="#" data-toggle="modal" data-target="#responsive-modal" onClick={()=>this.myFunction(el)} className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</button>


          In my function save the data in state and trigger the modal from there. Your state should be like



          this.state = {
          enableModal: false,
          data: null
          }






          share|improve this answer















          If i am understanding it correctly.
          Firstly why are you having method in template?



          You dont need anchor tag. you can have data in modal via function



          <button href="#" data-toggle="modal" data-target="#responsive-modal" onClick={()=>this.myFunction(el)} className="btn btn-success waves-effect waves-light m-t-20">UnSubscribe</button>


          In my function save the data in state and trigger the modal from there. Your state should be like



          this.state = {
          enableModal: false,
          data: null
          }







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 14 '18 at 5:07

























          answered Nov 14 '18 at 4:55









          shezshez

          257




          257













          • what is myFunction, IN that what will be there

            – sivasai081
            Nov 14 '18 at 5:01













          • IN my function i can access el but in the modal we are having button , from that button how to access that el

            – sivasai081
            Nov 14 '18 at 5:03











          • Thats because your modal is outside of individual.map function. You have to keep it inside the loop just like unsubscribe.

            – shez
            Nov 14 '18 at 5:09











          • @sivasai081 have you tried <button type="button" className="btn btn-danger" onClick={()=>this.withdrawPlan(el)}>Withdraw Plan</button> You need to bind withdrawPlan in constructor this.his.withdrawPlan = this.his.withdrawPlan.bind(this)

            – shez
            Nov 14 '18 at 6:04











          • yes i already binded

            – sivasai081
            Nov 14 '18 at 6:26



















          • what is myFunction, IN that what will be there

            – sivasai081
            Nov 14 '18 at 5:01













          • IN my function i can access el but in the modal we are having button , from that button how to access that el

            – sivasai081
            Nov 14 '18 at 5:03











          • Thats because your modal is outside of individual.map function. You have to keep it inside the loop just like unsubscribe.

            – shez
            Nov 14 '18 at 5:09











          • @sivasai081 have you tried <button type="button" className="btn btn-danger" onClick={()=>this.withdrawPlan(el)}>Withdraw Plan</button> You need to bind withdrawPlan in constructor this.his.withdrawPlan = this.his.withdrawPlan.bind(this)

            – shez
            Nov 14 '18 at 6:04











          • yes i already binded

            – sivasai081
            Nov 14 '18 at 6:26

















          what is myFunction, IN that what will be there

          – sivasai081
          Nov 14 '18 at 5:01







          what is myFunction, IN that what will be there

          – sivasai081
          Nov 14 '18 at 5:01















          IN my function i can access el but in the modal we are having button , from that button how to access that el

          – sivasai081
          Nov 14 '18 at 5:03





          IN my function i can access el but in the modal we are having button , from that button how to access that el

          – sivasai081
          Nov 14 '18 at 5:03













          Thats because your modal is outside of individual.map function. You have to keep it inside the loop just like unsubscribe.

          – shez
          Nov 14 '18 at 5:09





          Thats because your modal is outside of individual.map function. You have to keep it inside the loop just like unsubscribe.

          – shez
          Nov 14 '18 at 5:09













          @sivasai081 have you tried <button type="button" className="btn btn-danger" onClick={()=>this.withdrawPlan(el)}>Withdraw Plan</button> You need to bind withdrawPlan in constructor this.his.withdrawPlan = this.his.withdrawPlan.bind(this)

          – shez
          Nov 14 '18 at 6:04





          @sivasai081 have you tried <button type="button" className="btn btn-danger" onClick={()=>this.withdrawPlan(el)}>Withdraw Plan</button> You need to bind withdrawPlan in constructor this.his.withdrawPlan = this.his.withdrawPlan.bind(this)

          – shez
          Nov 14 '18 at 6:04













          yes i already binded

          – sivasai081
          Nov 14 '18 at 6:26





          yes i already binded

          – sivasai081
          Nov 14 '18 at 6:26


















          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%2f53292867%2fhow-to-access-data-in-the-modal-from-button-click%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







          這個網誌中的熱門文章

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Xamarin.form Move up view when keyboard appear

          JBPM : POST request for execute process go wrong