开发者

Jquery Impromptu > Go to URL

开发者 https://www.devze.com 2023-03-08 18:32 出处:网络
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.

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.

  1. Click on Logout – <a class="link" href="javascript:;" onclick="logout(1); ">Logout</a>

  2. Prompt 'Are you sure - Yes / No'

  3. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消