如何操作Jquery Accordian Header文本值 [英] How to manipulate Jquery Accordian Header text value

查看:63
本文介绍了如何操作Jquery Accordian Header文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jquery Accordian,它根据搜索结果创建嵌套的Accordians.

I am having a Jquery Accordian , which creates nested Accordians based on the search result .

这是我的jsfiddle

This is my jsfiddle

http://jsfiddle.net/DBYLk/25/

最初从数据库中获取数据时,我正在以绝对路径(POPCORN *** Bucket)获取文本

Initially While Fetching the Data from the Database i am fetching text it in absolute path (POPCORN***Bucket)

但是在以手风琴显示时,我只需要显示相对路径即可.(桶)

But while displaying it in accordian i need to show only the relative path .(Bucket)

当按一下Accoridan标头时,(Bucket)我需要发送整个POPCORN *** Bucket,以便搜索不会中断.

And when clciked on the Accoridan Header , (Bucket ) i need to send the whole POPCORN***Bucket , so that the search will not break .

(这是一个购物车应用程序,可能在其他类别中存在Bucket,并且搜索将给出错误的结果)

(This is a shoppping cart application and Bucket might exists for some other category and search will give wrong results)

这是负责在Jquery Accordians上显示标头的代码.

This is the code that is responsible for showing the header on Jquery Accordians.

html+="<div><a href='#'>" + response[i] + "</a></div><div id ='sample'></div>";

显示时,我可以显示 3星之后的最后一个值,但是当对此表示满意时,我需要将整个值发送给搜索.请让我知道这怎么可能?

While displaying i can show the last value after the 3 stars , but when clciked on that , i need to send the whole to the search . please let me know how this can be possible ??

我需要以某种方式将绝对路径和相对路径都存储在<div><a href='#'>" + response[i] + "</a>

Means i need to somehow store the both the absolute and relative paths under <div><a href='#'>" + response[i] + "</a>

我的问题可以简化,我可以将绝对路径存储在href属性中,单击该??时如何获取href属性值?

推荐答案

首先,您要为许多div附加相同的id,这是错误的. <div id="sample"> 其次,这会因您的JSON结构而变得有些困难.您是否有能力进行修改?这将使事情更容易处理.

Firstly, you are appending many divs with the same id which is wrong. <div id="sample"> Secondly this is made somewhat harder by your JSON structure. Do you have the ability to modify that at all? This would make things much easier to handle.

但是,您可以通过jQuery的data属性存储整个路径",并用任何内容代替basePath,例如

However you can store the entire "path" via jQuery's data attribute and replace the basePath with nothing e.g.

var tempName = response[i].replace(selectedeleemnt + "***", "");
html+="<div><a href='#' data-path='" + response[i] + "'>" + tempName + "</a></div><div id ='sample'></div>";

此外,JSON中的PopCorn需要统一,因为当前您拥有PopCorn然后是Popcorn***

Also the PopCorn in your JSON needs to be uniform as currently you have PopCorn and then Popcorn***

此后处理数据是通过检查hasData是否为hasData,然后使用它代替headerText来操纵selectedeleemnt的问题.

Handling the data thereafter is a matter of manipulating the selectedeleemnt by doing a check if it hasData and then using that instead of the headerText.

演示: http://jsfiddle.net/robschmuecker/DBYLk/33/

这篇关于如何操作Jquery Accordian Header文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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