做一个链接做2行动 [英] Make a link do 2 actions

查看:112
本文介绍了做一个链接做2行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何事情之前,我不知道如果我采取正确的方法,这个如此忍受我这一点。

Before anything, I don't know if I'm taking the right approach to this so bear with me on this.

我的问题是:我想要使用一个手风琴,其中每个选项卡是一类和扩展时,手风琴展示了艺术家的类别。到目前为止,一切都很好。

My problem is as follows: I'm trying to use an accordion where each tab is a category and when expanded, the accordion shows the artists in that category. So far, so good.

现在,我想要实现,另一部分是这样的:当我点击选项卡(其中有一个#链接)上我需要显示艺术家列表中的DIV,我正打算做AJAX。我能做到这一点没有问题,如果联系是内部的手风琴内容(例如,如果我想点击一个艺术家),但无法弄清楚如何使它单击选项卡时工作。

Now, the other part of what I'm trying to achieve is this: Once I click on the tab (which has a "#" link) I need to display the artists list in a div, which I was planning to do with AJAX. I can do this without problems if the link was INSIDE the accordion contents (for example, if I wanted to click on an artist) but can't figure out how to make it work when clicking a tab.

我的code如下:     

My code is as follows:

<li class="artistlist">
<a href="#">Photo</a>
<ul>
    <li><a href="artist.html">Artist</a></li>
    <li><a href="artist.html">Artist</a></li>
    <li><a href="artist.html">Artist</a></li>
</ul>
</li>
</ul>

<div id="contentbox">
<div id="artistcat">


</div>
</div><!-- /contentbox -->

和我想要做的是以下几点:像这样的东西代替HREF =#:     &LT; A HREF =JavaScript的:ajaxpage(ajaxed / abstrakt.html','contentbox');&GT;巴丁格&LT; / A&GT;

and what I'm trying to do is the following: replace href=# with something like this: <a href="javascript:ajaxpage('ajaxed/abstrakt.html', 'contentbox');">Abstrakt</a>

因此​​,在一个类别点击时(例如,​​照片),它扩展了手风琴(它不),并显示在AJAX中,这也正是手风琴只用缩略图的相同内容的内容。

thus, when clicking on a category (for example "photo") it expands the accordion (which it does) AND shows the content in the ajax box, which is exactly the same content of the accordion only with thumbnails.

因此​​,基本上,我需要做出的选项卡链接做动作2:1)扩大了手风琴和2)显示Ajax内容

So basically, I need to make that tab link do 2 actions: 1) expand the accordion and 2) show the ajax content.

我在想,也许AJAX的解决方案是错误的方式,无论哪种方式,任何帮助将大大AP preciated。

I'm thinking that perhaps the AJAX solution is the wrong way, either way, any help will be greatly appreciated.

推荐答案

尝试使用jQuery,并进行了小片的code,做你所需要的。

Try to use jQuery, and make a little piece of code that does what you need to.

如同

$('#contentbox').click( function() {
   $('#content').ajax( /* do ajax stuff */ );
   // animate accordion
});

这篇关于做一个链接做2行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆