Jquery Impromptu > Go to URL
After as much research as possible I don't have a working solution to what seems a simple problem.
I would like to use Jquery Impromptu.
Simple action.
Click on Logout –
<a class="link" href="javascript:;" onclick="logout(1); ">Logout</a>
Prompt 'Are you sure - Yes / No'
If Cancel, Nothing happens. If True go to a url 'logoutscript.php'.
I cannot get my thoughts to work and though I just cannot get my head around it. Any help would be really helpful.
++++++++++++++++++++++++++++++++++
function removeUser(id){
var txt = 'Are you sure you want to Logout?';
$.prompt(txt,{
buttons:{Logout:true, Cancel:false开发者_如何学Python},
callback: function(v,m,f){
<!-- This is wher the problem starts -->
++++++++++++++++++++++++++++++++++
a class="link" href="javascript:;" onclick="removeUser(1); ">Logout</a>
This should work:
HTML
<a class="link" href="#" data-id="1">Logout</a>
JS
function removeUser(id) {
var txt = 'Are you sure you want to Logout?';
$.prompt(txt, {
buttons: {
Logout: true,
Cancel: false
},
callback: function(accept) {
if (accept) {
window.location = "logoutscript.php";
}
return false;
}
});
}
$('a.link').click(function() {
removeUser($(this).data('id'));
return false;
});
You can as well call the method inline, if you need to.
For the future: Please provide complete and formatted code. In your list a method is called logout
, in the code sample removeUser
, then the code breaks up after an opening curly bracket.
精彩评论