javascript - jQuery 选择的 Css 问题

标签 javascript php jquery css jquery-chosen

我在管理面板的 post_form 页面上使用它时遇到问题,用于 Client: 字段。它适用于我的客户 artist_form,但在我的浏览器检查器中,它在 post_form 页面上显示错误。第一张截图来自 post_form,有错误,第二张截图来自 artist_form,我有你的好插件在工作,第三张我无法发布,因为我在这里没有足够的声誉,因为我是这个网站的新手将来 self 的 header.php,其中发布了指向 chosen.css 文件的链接。如果您能帮助我解决这个问题,我将不胜感激。

The first screenshot is from the post_form with the error

the second is from the artist_form where I have the plugin working

<script type="text/javascript">
// Post Form Validate
	$(document).ready(function () {
		$('#postForm').validate({
			errorElement: "div",
			rules: {
			    name: { required: true },
			    details: { required: true },
			    category: { required: true }
		  	}
		});
		$('#restform').click(function(){
            $('#postForm')[0].reset();
 		});
	});
// Chosen multi-select
	var config = {
	'.chosen-select' : {},
	'.chosen-select-deselect' : {allow_single_deselect:true},
	'.chosen-select-no-single' : {disable_search_threshold:10},
	'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
	'.chosen-select-width' : {width:"95%"}
	}
	for (var selector in config) {
	$(selector).chosen(config[selector]);
	} 
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>World Music Listing: Master Admin</title>
<link rel="stylesheet" href="public/css/screen.css" type="text/css" media="screen" title="default" />
<link rel="stylesheet" href="public/css/chosen.css">
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/pro_dropline_ie.css" />
<![endif]-->

<!--  jquery core -->
<script src="public/js/jquery/jquery.min.js" type="text/javascript"></script>
<script src="public/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="public/js/chosen.jquery.min.js" type="text/javascript"></script>
</head>
					<tr>					
						<th valign="top">Client:</th>
						<td>
						<?php	
							$host_name = "localhost";
							$database = "#my database name"; 		
							$username = "#my admin user name";       		
							$password = "#my password for the admin user";       	 	

							//////// Do not Edit below /////////
							try {
								$dbo = new PDO('mysql:host='.$host_name.';dbname='.$database, $username, $password);
								} catch (PDOException $e) {
								print "Error!: " . $e->getMessage() . "<br/>";
							die();
							}
							// Select all artists (clients) and order by name //
							$sql="SELECT aname FROM tbl_music_artists ORDER BY aname";
							// multi-select dropdown - select which artists (clients) receive posts //
						?>	
							<select name="userids[]" class="chosen-select" data-placeholder="Choose a Client..." style="width:350px;" multiple>
						<?php 
							foreach ($dbo->query($sql) as $row){
							echo "<option value=$row[id]>$row[aname]</option>";
							}
						?>
							</select>
						</td>
					</tr>		

最佳答案

我能够通过复制并重新粘贴 var config = { '.chosen-select' : {}, '.chosen-select-deselect' : {allow_single_deselect:true}, '.chosen- 来解决我的问题select-no-single' : {disable_search_threshold:10}, '.chosen-select-no-results': {no_results_text:'糟糕,找不到任何东西!'}, '.chosen-select-width' : {width:"95 %"} } ... 我的 post_form 底部的代码来自所选的 jquery。

关于javascript - jQuery 选择的 Css 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35785622/

相关文章:

javascript - Ember.getOwner 用于集成测试中的服务查找

javascript - AngularJS Controller 函数最佳实践

paypal-ipn - Paypal IPN 和 mail() 函数

javascript - 使用 HTML、Javascript 或 jQuery 嵌入本地托管视频的简单方法

jquery - 如何使用jQuery在Grails中创建弹出窗口

javascript - 输入是否具有 "original value"属性?

javascript - 如何在 php 中编写 javascript 代码

javascript - "You require appropriate loaders",使用 react native 和 expo。应用程序无法在 web 上编译,但在 android 上运行

php - 将多个数组合并为一个数组

php - ColdFusion 相当于 PHP openssl_sign()