社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Jquery

如何在jquery accordions中实现即时搜索

Jen • 5 年前 • 1428 次点击  

我对javascript很陌生,我试图将json数据绑定到手风琴上,但到目前为止,我似乎还不能正确地进行绑定。 jsfiddle

我怎么能在手风琴里立即搜索呢?

var contacts = [{
    "Title": "Change Management",
    "Definition": "Collective term for all approaches to prepare and support individuals, teams, and organizations in making organizational change. The most common change drivers include: technological evolution, process reviews, crisis, and consumer habit changes; pressure from new business entrants, acquisitions, mergers, and organizational restructuring. It includes methods that redirect or redefine the use of resources, business process, budget allocations, or other modes of operation that significantly change a company or organization. Organizational change management (OCM) considers the full organization and what needs to change,[3] while change management may be used solely to refer to how people and teams are affected by such organizational transition. It deals with many different disciplines, from behavioral and social sciences to information technology and business solutions. In a project-management context, the term "change management" may be used as an alternative to change control processes where in changes to the scope of a project are formally introduced and approved."
  },
  {
    "Title": "Testing glossary",
    "Definition": "Testing Text 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"
  },
  {
    "Title": "More info",
    "Definition": "Testing Text 1 but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but occasionally circumstances occur in which toil and pain"
  },
  {
    "Title": "Category 2",
    "Definition": "Testing Text 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
  }
];

var departmentlist = new Array();
$.each(contacts, function(i, contact) {
  //insert the departments
  if (contact.Title != null && $('#' + contact.Title).length == 0) {
    $('#accordion').append('<h3 id=' + contact.Title + '><a href="#">' + contact.Title + '</a></h3>');
    departmentlist.push(contact.Title);
  }
  //insert contacts in the accordion
  $('#' + contact.Title).after('<p><a' + contact.Definition + '</a></p>');
});
$.each(departmentlist, function(i, list) {
$("#" + list).nextUntil("h3").wrapAll("<div></div>");
});
});
$(function() {
      $("#accordion").accordion({
        collapsible: true,
        active: false,
      });
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" rel="stylesheet"/>

<div id="contactlist">
  <div id="accordion">

  </div>
</div>

更新2

有以下几点 code worked 通过扭转。这就是我目前在 SharePoint Site 似乎唯一不起作用的是搜索/突出显示。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/44324
 
1428 次点击  
文章 [ 1 ]  |  最新文章 5 年前