Return confirm cancel button not working
I have this link in twig :
<a href="{{ path('relation-delete', {'id': c.getCustomerId}) }}"
onclick="return confirm('{% trans %}relation.delete{% endtrans %}');"
class="tip" data-original-title="Verwijder klant {{ c.getCustomerName }}">
The HTML in the source :
<a href="/app_dev.php/projects/delete/1" class="tip"
data-original-title="Verwijder project Lantaarn plaatsen"
onclick="return confirm('Verwijderen');">
<button class="btn btn-danger"><i class="fa fa-times fa-fw"></i></button></a>`
the onlick confirm cancel button doesn't cancel the action but just keeps going.
Somebody knows what's wrong with this return confirm ?
javascript php html symfony twig
|
show 1 more comment
I have this link in twig :
<a href="{{ path('relation-delete', {'id': c.getCustomerId}) }}"
onclick="return confirm('{% trans %}relation.delete{% endtrans %}');"
class="tip" data-original-title="Verwijder klant {{ c.getCustomerName }}">
The HTML in the source :
<a href="/app_dev.php/projects/delete/1" class="tip"
data-original-title="Verwijder project Lantaarn plaatsen"
onclick="return confirm('Verwijderen');">
<button class="btn btn-danger"><i class="fa fa-times fa-fw"></i></button></a>`
the onlick confirm cancel button doesn't cancel the action but just keeps going.
Somebody knows what's wrong with this return confirm ?
javascript php html symfony twig
You have to show the result html, not template
– hindmost
Aug 19 '14 at 14:31
Add this into the question
– hindmost
Aug 19 '14 at 14:36
Done, any ideas on this ?
– Tommie
Aug 19 '14 at 14:38
any javascript errors in the console?
– reafle
Aug 19 '14 at 14:40
Why you placebutton
insidea
element?
– hindmost
Aug 19 '14 at 14:41
|
show 1 more comment
I have this link in twig :
<a href="{{ path('relation-delete', {'id': c.getCustomerId}) }}"
onclick="return confirm('{% trans %}relation.delete{% endtrans %}');"
class="tip" data-original-title="Verwijder klant {{ c.getCustomerName }}">
The HTML in the source :
<a href="/app_dev.php/projects/delete/1" class="tip"
data-original-title="Verwijder project Lantaarn plaatsen"
onclick="return confirm('Verwijderen');">
<button class="btn btn-danger"><i class="fa fa-times fa-fw"></i></button></a>`
the onlick confirm cancel button doesn't cancel the action but just keeps going.
Somebody knows what's wrong with this return confirm ?
javascript php html symfony twig
I have this link in twig :
<a href="{{ path('relation-delete', {'id': c.getCustomerId}) }}"
onclick="return confirm('{% trans %}relation.delete{% endtrans %}');"
class="tip" data-original-title="Verwijder klant {{ c.getCustomerName }}">
The HTML in the source :
<a href="/app_dev.php/projects/delete/1" class="tip"
data-original-title="Verwijder project Lantaarn plaatsen"
onclick="return confirm('Verwijderen');">
<button class="btn btn-danger"><i class="fa fa-times fa-fw"></i></button></a>`
the onlick confirm cancel button doesn't cancel the action but just keeps going.
Somebody knows what's wrong with this return confirm ?
javascript php html symfony twig
javascript php html symfony twig
edited Aug 19 '14 at 17:48
blackbishop
3,54313047
3,54313047
asked Aug 19 '14 at 14:28
TommieTommie
108212
108212
You have to show the result html, not template
– hindmost
Aug 19 '14 at 14:31
Add this into the question
– hindmost
Aug 19 '14 at 14:36
Done, any ideas on this ?
– Tommie
Aug 19 '14 at 14:38
any javascript errors in the console?
– reafle
Aug 19 '14 at 14:40
Why you placebutton
insidea
element?
– hindmost
Aug 19 '14 at 14:41
|
show 1 more comment
You have to show the result html, not template
– hindmost
Aug 19 '14 at 14:31
Add this into the question
– hindmost
Aug 19 '14 at 14:36
Done, any ideas on this ?
– Tommie
Aug 19 '14 at 14:38
any javascript errors in the console?
– reafle
Aug 19 '14 at 14:40
Why you placebutton
insidea
element?
– hindmost
Aug 19 '14 at 14:41
You have to show the result html, not template
– hindmost
Aug 19 '14 at 14:31
You have to show the result html, not template
– hindmost
Aug 19 '14 at 14:31
Add this into the question
– hindmost
Aug 19 '14 at 14:36
Add this into the question
– hindmost
Aug 19 '14 at 14:36
Done, any ideas on this ?
– Tommie
Aug 19 '14 at 14:38
Done, any ideas on this ?
– Tommie
Aug 19 '14 at 14:38
any javascript errors in the console?
– reafle
Aug 19 '14 at 14:40
any javascript errors in the console?
– reafle
Aug 19 '14 at 14:40
Why you place
button
inside a
element?– hindmost
Aug 19 '14 at 14:41
Why you place
button
inside a
element?– hindmost
Aug 19 '14 at 14:41
|
show 1 more comment
2 Answers
2
active
oldest
votes
You can validade the confirm box outside of html element, in a function and, call this function on 'onclick' event. Like this:
<a href="somePage" onclick="return myFunction()">My link</a>
function myFunction() {
if (confirm("Confirm message")) {
// do stuff
} else {
return false;
}
}
It turns out this was causing the problem in a other javascript file:$("a").click(function(e) { e.preventDefault(); location.href = $(this).attr("href"); });
– Tommie
Aug 21 '14 at 14:52
add a comment |
Adding event.preventDefault();
fixed it.
Here is an example:
console.log('Validating...');
function confirm_delete(){
var txt;
var r = confirm("Are you sure you want to delete?");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
event.preventDefault();
}
console.log(txt);
}
or that "return false;" statement would do the trick to I suppose, I missed it when I was reading it first...
– Dhruv
Nov 24 '18 at 23:02
add a comment |
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%2f25386032%2freturn-confirm-cancel-button-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can validade the confirm box outside of html element, in a function and, call this function on 'onclick' event. Like this:
<a href="somePage" onclick="return myFunction()">My link</a>
function myFunction() {
if (confirm("Confirm message")) {
// do stuff
} else {
return false;
}
}
It turns out this was causing the problem in a other javascript file:$("a").click(function(e) { e.preventDefault(); location.href = $(this).attr("href"); });
– Tommie
Aug 21 '14 at 14:52
add a comment |
You can validade the confirm box outside of html element, in a function and, call this function on 'onclick' event. Like this:
<a href="somePage" onclick="return myFunction()">My link</a>
function myFunction() {
if (confirm("Confirm message")) {
// do stuff
} else {
return false;
}
}
It turns out this was causing the problem in a other javascript file:$("a").click(function(e) { e.preventDefault(); location.href = $(this).attr("href"); });
– Tommie
Aug 21 '14 at 14:52
add a comment |
You can validade the confirm box outside of html element, in a function and, call this function on 'onclick' event. Like this:
<a href="somePage" onclick="return myFunction()">My link</a>
function myFunction() {
if (confirm("Confirm message")) {
// do stuff
} else {
return false;
}
}
You can validade the confirm box outside of html element, in a function and, call this function on 'onclick' event. Like this:
<a href="somePage" onclick="return myFunction()">My link</a>
function myFunction() {
if (confirm("Confirm message")) {
// do stuff
} else {
return false;
}
}
answered Aug 19 '14 at 17:40
Helam.DevHelam.Dev
562
562
It turns out this was causing the problem in a other javascript file:$("a").click(function(e) { e.preventDefault(); location.href = $(this).attr("href"); });
– Tommie
Aug 21 '14 at 14:52
add a comment |
It turns out this was causing the problem in a other javascript file:$("a").click(function(e) { e.preventDefault(); location.href = $(this).attr("href"); });
– Tommie
Aug 21 '14 at 14:52
It turns out this was causing the problem in a other javascript file:
$("a").click(function(e) { e.preventDefault(); location.href = $(this).attr("href"); });
– Tommie
Aug 21 '14 at 14:52
It turns out this was causing the problem in a other javascript file:
$("a").click(function(e) { e.preventDefault(); location.href = $(this).attr("href"); });
– Tommie
Aug 21 '14 at 14:52
add a comment |
Adding event.preventDefault();
fixed it.
Here is an example:
console.log('Validating...');
function confirm_delete(){
var txt;
var r = confirm("Are you sure you want to delete?");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
event.preventDefault();
}
console.log(txt);
}
or that "return false;" statement would do the trick to I suppose, I missed it when I was reading it first...
– Dhruv
Nov 24 '18 at 23:02
add a comment |
Adding event.preventDefault();
fixed it.
Here is an example:
console.log('Validating...');
function confirm_delete(){
var txt;
var r = confirm("Are you sure you want to delete?");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
event.preventDefault();
}
console.log(txt);
}
or that "return false;" statement would do the trick to I suppose, I missed it when I was reading it first...
– Dhruv
Nov 24 '18 at 23:02
add a comment |
Adding event.preventDefault();
fixed it.
Here is an example:
console.log('Validating...');
function confirm_delete(){
var txt;
var r = confirm("Are you sure you want to delete?");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
event.preventDefault();
}
console.log(txt);
}
Adding event.preventDefault();
fixed it.
Here is an example:
console.log('Validating...');
function confirm_delete(){
var txt;
var r = confirm("Are you sure you want to delete?");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
event.preventDefault();
}
console.log(txt);
}
answered Nov 24 '18 at 23:01
DhruvDhruv
314
314
or that "return false;" statement would do the trick to I suppose, I missed it when I was reading it first...
– Dhruv
Nov 24 '18 at 23:02
add a comment |
or that "return false;" statement would do the trick to I suppose, I missed it when I was reading it first...
– Dhruv
Nov 24 '18 at 23:02
or that "return false;" statement would do the trick to I suppose, I missed it when I was reading it first...
– Dhruv
Nov 24 '18 at 23:02
or that "return false;" statement would do the trick to I suppose, I missed it when I was reading it first...
– Dhruv
Nov 24 '18 at 23:02
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.
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%2f25386032%2freturn-confirm-cancel-button-not-working%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 have to show the result html, not template
– hindmost
Aug 19 '14 at 14:31
Add this into the question
– hindmost
Aug 19 '14 at 14:36
Done, any ideas on this ?
– Tommie
Aug 19 '14 at 14:38
any javascript errors in the console?
– reafle
Aug 19 '14 at 14:40
Why you place
button
insidea
element?– hindmost
Aug 19 '14 at 14:41