以下是Jquery Chosen插件的页面(和演示)。这非常方便。Jquery选择插件样式Ajax调用后丢失
http://harvesthq.github.io/chosen/
所以我的问题是,我使用的是2级输入形式收集位置信息。 第一个选择菜单是针对国家的。选择一个国家后,第二个输入字段仅显示该字段的国家选项。Neato!
这里是我的问题的现场演示。
你会发现,Ajax调用的作品,但一旦返回的第二场,造型丢失! =(
据插件
的选择菜单必须在一定的HTML框架内
<select data-placeholder="Select City" class="chzn-select" style="width:350px;" tabindex="2" name="city">
<? while($row=mysql_fetch_array($result)) { ?>
<option class="active-result option"
style="padding: 5px 0px 5px 0px; font-family:arial; font-size:12px;"
><?=$row['city']?></option>
<? } ?>
</select>
这在技术上应该工作,但没有。 任何线索,如何保持造型通话结束后?
这里是正在返回的PHP页面
<!--//---------------------------------+
// Developed by Roshan Bhattarai |
// http://roshanbh.com.np |
// Contact for custom scripts |
// or implementation help. |
// [email protected] |
//---------------------------------+-->
<?
#### Roshan's Ajax dropdown code with php
#### Copyright reserved to Roshan Bhattarai - [email protected]
#### if you have any problem contact me at http://roshanbh.com.np
#### fell free to visit my blog http://php-ajax-guru.blogspot.com
?>
<? $country = $_GET['country'];
$link = mysql_connect("SNIP");
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('SNIP');
$query="SELECT city FROM location WHERE country='$country' ORDER BY `city` ASC";
$result=mysql_query($query);
?>
<div class="x">
<br>
<select data-placeholder="Select City" class="chzn-select" style="width:350px;" tabindex="2" name="city">
<? while($row=mysql_fetch_array($result)) { ?>
<option class="active-result option"><?=$row['city']?></option>
<? } ?>
</select>
</div>
后在正确的位置注意HTML元素被替换,所以你CSS样式停止工作 – raam86
@ raam86有没有一种方法来刷新CSS的新魔法工作HTML? –
CSS总是起着魔力。你新的元素不携带相同的类,等等'所以CSS不起作用 – raam86