How to access data in the modal from button click?
{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
add a comment |
{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
add a comment |
{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
{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
javascript reactjs bootstrap-modal
edited Nov 14 '18 at 5:44
sivasai081
asked Nov 14 '18 at 3:40
sivasai081sivasai081
237
237
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
}
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
|
show 2 more comments
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
}
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
|
show 2 more comments
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
}
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
|
show 2 more comments
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
}
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
}
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
|
show 2 more comments
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
|
show 2 more comments
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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