how to set bootstrap modal as confirm dialog?
up vote
0
down vote
favorite
how to set bootstrap modal as confirm window i am try this code but it returns true when modal is open.
this code not work it allow to redirect. before show a modal.
bootstrap modal:
<a href="https/www.google.com" id="btn-confirm">Confirm</a>
<div id="deletemodel" class="modal fade">
<div class="modal-dialog modal-confirm">
<div class="modal-content">
<div class="modal-header"> </div>
<div class="modal-body">
<p>Do you really want to delete these record? This process cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info deleteCancel">Cancel</button>
<button type="button" class="btn btn-danger deleteConfirm">Delete</button>
</div>
</div>
</div>
Script
<script>
var modalConfirm = function(callback){
$("#btn-confirm").on("click", function(){
$("#deletemodel").modal('show');
});
$("#deletemodel .deleteConfirm").on("click", function(){
callback(true);
$("#deletemodel").modal('hide');
});
$("#deletemodel .deleteCancel").on("click", function(){
callback(false);
$("#deletemodel").modal('hide');
});
};
modalConfirm(function(confirm){
if(confirm){
return true;
}else{
return false;
}
});
</script>
anybody can help me to solve this problem?
jquery twitter-bootstrap
add a comment |
up vote
0
down vote
favorite
how to set bootstrap modal as confirm window i am try this code but it returns true when modal is open.
this code not work it allow to redirect. before show a modal.
bootstrap modal:
<a href="https/www.google.com" id="btn-confirm">Confirm</a>
<div id="deletemodel" class="modal fade">
<div class="modal-dialog modal-confirm">
<div class="modal-content">
<div class="modal-header"> </div>
<div class="modal-body">
<p>Do you really want to delete these record? This process cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info deleteCancel">Cancel</button>
<button type="button" class="btn btn-danger deleteConfirm">Delete</button>
</div>
</div>
</div>
Script
<script>
var modalConfirm = function(callback){
$("#btn-confirm").on("click", function(){
$("#deletemodel").modal('show');
});
$("#deletemodel .deleteConfirm").on("click", function(){
callback(true);
$("#deletemodel").modal('hide');
});
$("#deletemodel .deleteCancel").on("click", function(){
callback(false);
$("#deletemodel").modal('hide');
});
};
modalConfirm(function(confirm){
if(confirm){
return true;
}else{
return false;
}
});
</script>
anybody can help me to solve this problem?
jquery twitter-bootstrap
You are 90% done. You got the basics but you are missing some pieces. First you can define the modal to reference it whenever you need it (HTML file). Then on your script whenever you need it, you can set the "this.modal = <referenceToYourHTML>". Note that you will need to define the modalView, and the reference. Hope this helps you figuring things out.
– Cabrra
Nov 22 at 14:05
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
how to set bootstrap modal as confirm window i am try this code but it returns true when modal is open.
this code not work it allow to redirect. before show a modal.
bootstrap modal:
<a href="https/www.google.com" id="btn-confirm">Confirm</a>
<div id="deletemodel" class="modal fade">
<div class="modal-dialog modal-confirm">
<div class="modal-content">
<div class="modal-header"> </div>
<div class="modal-body">
<p>Do you really want to delete these record? This process cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info deleteCancel">Cancel</button>
<button type="button" class="btn btn-danger deleteConfirm">Delete</button>
</div>
</div>
</div>
Script
<script>
var modalConfirm = function(callback){
$("#btn-confirm").on("click", function(){
$("#deletemodel").modal('show');
});
$("#deletemodel .deleteConfirm").on("click", function(){
callback(true);
$("#deletemodel").modal('hide');
});
$("#deletemodel .deleteCancel").on("click", function(){
callback(false);
$("#deletemodel").modal('hide');
});
};
modalConfirm(function(confirm){
if(confirm){
return true;
}else{
return false;
}
});
</script>
anybody can help me to solve this problem?
jquery twitter-bootstrap
how to set bootstrap modal as confirm window i am try this code but it returns true when modal is open.
this code not work it allow to redirect. before show a modal.
bootstrap modal:
<a href="https/www.google.com" id="btn-confirm">Confirm</a>
<div id="deletemodel" class="modal fade">
<div class="modal-dialog modal-confirm">
<div class="modal-content">
<div class="modal-header"> </div>
<div class="modal-body">
<p>Do you really want to delete these record? This process cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info deleteCancel">Cancel</button>
<button type="button" class="btn btn-danger deleteConfirm">Delete</button>
</div>
</div>
</div>
Script
<script>
var modalConfirm = function(callback){
$("#btn-confirm").on("click", function(){
$("#deletemodel").modal('show');
});
$("#deletemodel .deleteConfirm").on("click", function(){
callback(true);
$("#deletemodel").modal('hide');
});
$("#deletemodel .deleteCancel").on("click", function(){
callback(false);
$("#deletemodel").modal('hide');
});
};
modalConfirm(function(confirm){
if(confirm){
return true;
}else{
return false;
}
});
</script>
anybody can help me to solve this problem?
jquery twitter-bootstrap
jquery twitter-bootstrap
asked Nov 22 at 13:56
VIJAY
155
155
You are 90% done. You got the basics but you are missing some pieces. First you can define the modal to reference it whenever you need it (HTML file). Then on your script whenever you need it, you can set the "this.modal = <referenceToYourHTML>". Note that you will need to define the modalView, and the reference. Hope this helps you figuring things out.
– Cabrra
Nov 22 at 14:05
add a comment |
You are 90% done. You got the basics but you are missing some pieces. First you can define the modal to reference it whenever you need it (HTML file). Then on your script whenever you need it, you can set the "this.modal = <referenceToYourHTML>". Note that you will need to define the modalView, and the reference. Hope this helps you figuring things out.
– Cabrra
Nov 22 at 14:05
You are 90% done. You got the basics but you are missing some pieces. First you can define the modal to reference it whenever you need it (HTML file). Then on your script whenever you need it, you can set the "this.modal = <referenceToYourHTML>". Note that you will need to define the modalView, and the reference. Hope this helps you figuring things out.
– Cabrra
Nov 22 at 14:05
You are 90% done. You got the basics but you are missing some pieces. First you can define the modal to reference it whenever you need it (HTML file). Then on your script whenever you need it, you can set the "this.modal = <referenceToYourHTML>". Note that you will need to define the modalView, and the reference. Hope this helps you figuring things out.
– Cabrra
Nov 22 at 14:05
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Just change a couple lines in your JS :
$('#btn-confirm').on('click', function(e) {
e.preventDefault();// <--- This line.
$('#deletemodel').modal('show');
});
e
is the click event.preventDefault
tells the browser not to follow the HTML default behavior (which usually prepends to the JS behavior).
$('#deletemodel .deleteCancel').on('click', function() {
location.href = 'https://google.com'
});
sorry, it works but after click modal deleteConfirm button it will not redirect.
– VIJAY
Nov 23 at 7:17
Oh, yeah, you have to manually redirect usinglocation.href = "https://google.com"
. Editing the answer... Done.
– Jean-Marc Zimmer
Nov 23 at 7:20
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Just change a couple lines in your JS :
$('#btn-confirm').on('click', function(e) {
e.preventDefault();// <--- This line.
$('#deletemodel').modal('show');
});
e
is the click event.preventDefault
tells the browser not to follow the HTML default behavior (which usually prepends to the JS behavior).
$('#deletemodel .deleteCancel').on('click', function() {
location.href = 'https://google.com'
});
sorry, it works but after click modal deleteConfirm button it will not redirect.
– VIJAY
Nov 23 at 7:17
Oh, yeah, you have to manually redirect usinglocation.href = "https://google.com"
. Editing the answer... Done.
– Jean-Marc Zimmer
Nov 23 at 7:20
add a comment |
up vote
0
down vote
Just change a couple lines in your JS :
$('#btn-confirm').on('click', function(e) {
e.preventDefault();// <--- This line.
$('#deletemodel').modal('show');
});
e
is the click event.preventDefault
tells the browser not to follow the HTML default behavior (which usually prepends to the JS behavior).
$('#deletemodel .deleteCancel').on('click', function() {
location.href = 'https://google.com'
});
sorry, it works but after click modal deleteConfirm button it will not redirect.
– VIJAY
Nov 23 at 7:17
Oh, yeah, you have to manually redirect usinglocation.href = "https://google.com"
. Editing the answer... Done.
– Jean-Marc Zimmer
Nov 23 at 7:20
add a comment |
up vote
0
down vote
up vote
0
down vote
Just change a couple lines in your JS :
$('#btn-confirm').on('click', function(e) {
e.preventDefault();// <--- This line.
$('#deletemodel').modal('show');
});
e
is the click event.preventDefault
tells the browser not to follow the HTML default behavior (which usually prepends to the JS behavior).
$('#deletemodel .deleteCancel').on('click', function() {
location.href = 'https://google.com'
});
Just change a couple lines in your JS :
$('#btn-confirm').on('click', function(e) {
e.preventDefault();// <--- This line.
$('#deletemodel').modal('show');
});
e
is the click event.preventDefault
tells the browser not to follow the HTML default behavior (which usually prepends to the JS behavior).
$('#deletemodel .deleteCancel').on('click', function() {
location.href = 'https://google.com'
});
edited Nov 23 at 7:21
answered Nov 22 at 15:51
Jean-Marc Zimmer
36914
36914
sorry, it works but after click modal deleteConfirm button it will not redirect.
– VIJAY
Nov 23 at 7:17
Oh, yeah, you have to manually redirect usinglocation.href = "https://google.com"
. Editing the answer... Done.
– Jean-Marc Zimmer
Nov 23 at 7:20
add a comment |
sorry, it works but after click modal deleteConfirm button it will not redirect.
– VIJAY
Nov 23 at 7:17
Oh, yeah, you have to manually redirect usinglocation.href = "https://google.com"
. Editing the answer... Done.
– Jean-Marc Zimmer
Nov 23 at 7:20
sorry, it works but after click modal deleteConfirm button it will not redirect.
– VIJAY
Nov 23 at 7:17
sorry, it works but after click modal deleteConfirm button it will not redirect.
– VIJAY
Nov 23 at 7:17
Oh, yeah, you have to manually redirect using
location.href = "https://google.com"
. Editing the answer... Done.– Jean-Marc Zimmer
Nov 23 at 7:20
Oh, yeah, you have to manually redirect using
location.href = "https://google.com"
. Editing the answer... Done.– Jean-Marc Zimmer
Nov 23 at 7:20
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53432561%2fhow-to-set-bootstrap-modal-as-confirm-dialog%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
You are 90% done. You got the basics but you are missing some pieces. First you can define the modal to reference it whenever you need it (HTML file). Then on your script whenever you need it, you can set the "this.modal = <referenceToYourHTML>". Note that you will need to define the modalView, and the reference. Hope this helps you figuring things out.
– Cabrra
Nov 22 at 14:05