jQuery自动分压器直到在过滤器框中输入内容才加载
jQuery autodividers don't load until something is typed in the filter box
我试图使一个网站与三个类别和一个过滤框通过它们进行搜索。我也试图使用字母自动分压器,然而,这些不加载,直到在过滤框中键入的东西。我也不能让jQuery在Chrome上工作。有办法让自动分割器工作吗?我想也许jQuery没有及时加载,但尝试了窗口。加载和没有乐趣,我还包括document.ready。这基本上就是我想做的,但这个人对我做了很多不同的事情。http://site320.webelevate.net/Jquery/
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).ready( function() {
$.getJSON("starTrek.json", function(data){
$.each(data.enterprise.humans, function(){
$("ul#humans").append('<li>' + '<a href="#' + this["url"] + '"">'+ this["firstName"] + ' ' + this["lastName"] + '</a>' + '</li>');
});
$.each(data.enterprise.robots, function(){
$("ul#robots").append('<li>' + '<a href="#' + this["url"] + '"">'+this["firstName"] + ' ' + this["lastName"] + '</a>' + '</li>');
});
$.each(data.enterprise.wesley, function(){
$("ul#wesley").append('<li>' + '<a href="#' + this["url"] + '"">'+ this["firstName"] + ' ' + this["lastName"] + '</a>' + '</li>');
});
});
});
</script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>Star Trek: The Next Generation</h1>
</div><!-- /header -->
<div data-role="collapsible">
<h2>Humans</h2>
<ul id="humans" data-role="listview" data-filter="true" data-icon="user" data-autodividers="true">
</ul>
</div>
<div data-role="collapsible">
<h2>Robots</h2>
<ul id="robots" data-role="listview" data-filter="true" data-icon="gear" data-autodividers="true">
</ul>
</div>
<div data-role="collapsible">
<h2>Wesley</h2>
<ul id="wesley" data-role="listview" data-filter="true" data-icon="forbidden" data-autodividers="true">
</ul>
</div>
</ul>
</div>
<div data-role="page" id="picard">
<p>Jean-Luc Picard was a celebrated Starfleet officer, archaeologist and diplomat who served during the latter two thirds of the 24th century. The highlights of his career were centered around assignments as commanding officer of the Federation starships: USS Stargazer, USS Enterprise-D, and the USS Enterprise-E. In these roles, Picard not only witnessed the major turning points of recent galactic history, but played a key role in them also, from making first contact as captain of the Federation's flagship with no fewer than 27 alien species, including the Ferengi and the Borg. He also became the chief contact point with the Q Continuum, and served as Arbiter of Succession, where he presided over the investiture of Chancellor Gowron.</p>
</div>
<div data-role="page" id="riker">
<p>William Thomas Riker was a noted Starfleet officer, perhaps best known for his long assignment as first officer under Captain Jean-Luc Picard aboard the USS Enterprise-D, and later the USS Enterprise-E. In 2379, he finally accepted a promotion as captain of the USS Titan. In 2361, a transporter accident resulted in two Rikers, with each one being identical to the other, as well as genetically indistinguishable. Their personality and memories were the same up to the point of the duplication. The other Riker eventually decided to use his middle name and became known as Thomas Riker.</p>
</div>
<div data-role="page" id="worf">
<!-- I'm only on season 4 of DS9, this just totally spoilered me. -->
<p>Worf – son of Mogh, of the Klingon House of Martok, of the Human family Rozhenko; mate to K'Ehleyr, father to Alexander Rozhenko, and husband to Jadzia Dax; Starfleet officer and soldier of the Empire; bane of the House of Duras; slayer of Gowron; Federation ambassador to Qo'noS – was one of the most influential Klingons of the latter half of the 24th century. </p>
</div>
<div data-role="page" id="data">
<p>Lieutenant Commander Data was a Soong-type android, the first and only such being to ever enter Starfleet. Data was created some time in the 2330s and was destroyed in 2379, sacrificing himself to save the crew of the USS Enterprise-E. </p>
</div>
<div data-role="page" id="crusher">
<p>Commander Beverly Cheryl Crusher, MD, (née Howard) was the chief medical officer aboard the USS Enterprise-D and its successor, the USS Enterprise-E, both under the command of Captain Jean-Luc Picard. She briefly left her post as CMO of the Enterprise-D to become head of Starfleet Medical, only to return shortly after. She was a Fellow of the Academy of Starfleet Surgeons.</p>
</div>
<div data-role="page" id="troi">
<p>Deanna Troi was a half-Betazoid, half-Human Starfleet officer. Under the command of Captain Jean-Luc Picard, she served as ship's counselor aboard the USS Enterprise-D and the USS Enterprise-E. In 2379, Troi transferred to the USS Titan. As a half-Betazoid, Troi was capable of extra-sensory empathy, but was incapable of reading aliens with brain structures dissimilar to Humans and other Betazoids, such as the Breen and the Ferengi. Like most Betazoids, Troi had telepathic abilities. Due to her half-Human heritage, however, the range of her telepathic abilities was limited compared to full-blooded Betazoids, and she could usually only read the thoughts of other Betazoids, most notably her mother. Troi's empathic skills made her an important asset to the Enterprise-D and her abilities were often particularly useful when dealing with hostile races. Since she could usually determine using her abilities whether others were lying, she repeatedly proved herself invaluable in many suspenseful situations.</p>
</div>
<div data-role="page" id="obrien">
<p>Miles Edward O'Brien was a 24th century Human Starfleet non-commissioned officer who, following his service during the Federation-Cardassian War, served as transporter chief on board the USS Enterprise-D for several years before being promoted to chief of operations aboard starbase Deep Space 9. After the Dominion War, he accepted a teaching position at Starfleet Academy on Earth.</p>
</div>
<div data-role="page" id="wesley">
<p>When Wesley was only five years old, his father, Jack Crusher, was killed while on duty on the USS Stargazer under the command of Captain Jean-Luc Picard. Ten years later, fifteen-year-old Wesley found himself living aboard the starship USS Enterprise-D when his mother, Doctor Beverly Crusher became Captain Picard's chief medical officer aboard the ship. Wesley often was a challenge and sore sight in the captain's eyes, because of the captain's disdain for children, although Wesley's astuteness and knowledge of engineering, as well as top grades on scientific examinations continuously impressed Picard. These same characteristics were, in part, the cause of Wesley suffering from loneliness early on, as his peers were intimidated by his bright mind – he also showed a tendency to take his duties almost too seriously.</p>
</body>
</html>
JSON: {
"enterprise": {
"humans": [
{ "firstName":"Jean Luc" , "lastName":"Picard" , "url":"picard"},
{ "firstName":"Will" , "lastName":"Riker" , "url":"riker"},
{ "firstName":"Mr" , "lastName":"Worf" , "url":"worf"},
{ "firstName":"Beverly" , "lastName":"Crusher" , "url":"crusher"},
{ "firstName":"Deanna" , "lastName":"Troi" , "url":"troi" },
{ "firstName":"Miles" , "lastName":"O'Brien" , "url":"obrien"}
],
"robots": [
{ "firstName":"Data" , "lastName":" " , "url":"data"}
],
"wesley": [
{ "firstName":"Shut up" , "lastName":"Wesley" , "url":"wesley"}
]
}
}
强制Javascript重新加载修复。
<script>
$(document).ready( function() {
$.getJSON("starTrek.json", function(data){
$.each(data.enterprise.humans, function(){
$("ul#humans").append('<li>' + '<a href="#' + this["url"] + '"">'+ this["firstName"] + ' ' + this["lastName"] + '</a>' + '</li>');
$("ul#[humans]").refresh;
});
$.each(data.enterprise.robots, function(){
$("ul#robots").append('<li>' + '<a href="#' + this["url"] + '"">'+this["firstName"] + ' ' + this["lastName"] + '</a>' + '</li>');
$("ul#[robots]").refresh;
});
$.each(data.enterprise.wesley, function(){
$("ul#wesley").append('<li>' + '<a href="#' + this["url"] + '"">'+ this["firstName"] + ' ' + this["lastName"] + '</a>' + '</li>');
$("ul#[wesley]").refresh;
});
});
});
</script>
相关文章:
- Ajax文件加载和<输入>文件加载
- 如果图像标记是用javascript编写的,并且需要用户输入,那么图像不会随页面加载吗
- 在Chrome中重新加载页面后清除表单输入值
- 向使用jQuery加载DOM后添加的字段添加不受限制的文本输入DatePickers
- 如何使用输入数据加载新的extjs图表
- 输入上的键控事件在页面加载时触发
- Selectize.js:如何将数据库中已经选择的标签预加载到输入字段(Meteor&MongoDB/JSON)
- 如何在页面加载时直接使用Javascript在输入字段中填写数据
- HTML5范围输入重新加载
- 将从服务器获取的数据加载到输入文本表单中
- 验证嵌套在ng中的输入元素repeat也用于页面加载,而不仅仅用于更改
- 使用回调函数时,加载会覆盖输入文本框
- 在Meteor中加载带有采集数据的选择输入字段
- 无法为动态加载的输入框加载日期选择器和小部件
- 当在ng重复中使用ng模型时,在页面加载时角度输入不为空
- 传递数据以填充在ajax Modal中加载的输入字段
- 从用户输入加载 JSON 文件
- 根据用户输入加载不同的表单
- 检测图像输入加载
- 表单输入加载替换