【发布时间】:2009-08-26 17:41:33
【问题描述】:
我正在尝试为应用程序创建标签云。当我从标签云中单击标签时,标签的背景必须更改。这里有一个简单的标签html代码:
<a about="http://localhost/d456c6" href="http://localhost/d456c6" class="tagweight0 Resource">abda</a>
要更改背景,我使用以下方法:
$('tagweight0').livequery('click', function(event) {
$(this).toggleClass("select");
return false;
});
未选中标签的网址如下所示:
http://localhost/exploretags/
当我选择了标签时,它必须类似于(JSON 格式):
http://localhost/exploretags/?selectedTags={"0" : "uri0", "1" : "uri1" , "2" : "uri2"}
我可以使用 $.post 来加载页面。我的问题是,我不知道如何生成 selectedTags 参数的值。点击标签时必须在 selectedTag 中添加一个元素,再次点击同一标签时必须删除,例如
- 不带选定标签的标签
- 点击标签“abc”,加载的url为http://localhost/exploretags/?selectedTags={"0" : "http://localhost/tags/abc"}
- 点击标签“def”,加载的url为http://localhost/exploretags/?selectedTags={"0" : "http://localhost/tags/abc", "1" : "http://localhost/tags/def"}
- 点击标签“abc”。要加载的网址是 http://localhost/exploretags/?selectedTags={"0" : "http://localhost/tags/def"}
我的想法是编写一个帮助函数,它可以获取所有具有更改背景的标签的 uri。但我不知道,如何为 selectedTags 参数构建 {} 之间的部分。
谁能给我一个想法,如何制作这个?我的方法正确吗?
问候, 西拉科夫
PS。对不起,很长的帖子和糟糕的英语
【问题讨论】:
标签: jquery json post parameters