开发者

Load Ajax In Modal

I have a great modal script I'm using, that loads a page via ajax. However the href is left blank. This means I'll need to create a new id for each link. Is their a way to use this with just one script and have it load the correct link via ajax and have the title be the title in the link. Here's the script.

    <a id="ajax2" href="#" onClick="self.location=this.href; return false">
    $('#ajax2').click(function(){
        lightbox.alert({
            width: '400px',
            title: 'Gamerholic.com Sign Up/Log In',
            rightButtons: ['Close'],
            background: 'black',
            fade: 'false',

            opened: function(){
                $('<span />').load('./login.php').appendTo('#lbC开发者_如何学编程ontent');
            },
            buttonClick: function(button){
                console.log(button);
            }
        });
    });


I dont really get your question. You want a dynamic link which gives a url and a title?

i created a click on the class which grabs the href + title of the link and uses it in your code, is this what you mean?

<a class="classname" href="./login.php" title="your title">

you js:

$('.classname').click(function(){
        var url = $(this).attr('href'); //get the attribute href
        var title = $(this).attr('title'); //get the attribute href

        lightbox.alert({
        width: '400px',
        title: title,
        rightButtons: ['Close'],
        background: 'black',
        fade: 'false',

        opened: function(){
            $('<span />').load(url).appendTo('#lbContent');
        },
        buttonClick: function(button){
            console.log(button);
        }
    });
    return false;
});


If I understand your question correctly:

<a class="ajax" href="#" url="login.php" title="Login" onClick="self.location=this.href; return false">
<a class="ajax" href="#" url="register.php" title="Register" onClick="self.location=this.href; return false">
$('.ajax').click(function(){
    lightbox.alert({
        width: '400px',
        title: $(this).attr('title'),
        rightButtons: ['Close'],
        background: 'black',
        fade: 'false',

        opened: function(){
            $('<span />').load($(this).attr('url')).appendTo('#lbContent');
        },
        buttonClick: function(button){
            console.log(button);
        }
    });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜