早上好,
我已经开始构建我的第一个单页面应用程序的HTML元素。我需要为特定输入调用JQuery Multi Select。我在我的html文件中包含了脚本标记。但是,它根本没有渲染。
<script>
$(document).ready(function () {
$("#Sites").multiselect();
});
</script>
<section>
<h2 class="page-title" data-bind="text: title"></h2>
</section>
<section id ="Recipients">
<article>
<div class="row">
<div class="span6">
<label for="Study">Study: </label>
<select data-bind="text: Study" title="Study"></select><br />
<label for="Sites">Sites: </label>
<select data-bind="text: Sites" title="Sites" multiple="multiple" ></select><br />
<label for="Distribution">Distribution: </label>
<input type="checkbox" data-bind="text: Distribution" title="Distribution" />
</div><!-- span6 -->
</div><!-- row -->
<div class="row">
<div class="span6">
<label for="Recipients">Recipients: </label>
<input type="checkbox" data-bind="text: Recipients" title="Recipients"/><br />
</div><!-- span8 -->
</div><!-- row -->
</article>
</section>
<section id ="Communication">
<article>
<label for="SendFrom">Send From: </label>
<label id="SendFrom"></label><br />
<label for="Subject">Subject: </label>
<input id="Subject" /><br />
</article>
</section>
我是否将脚本标记放在正确的文件中?它应该在我的home.js文件中吗? HTML文件是否需要引用附加的样式表和JavaScript文件,或者Durandal / KO是否在幕后处理此问题?
答案 0 :(得分:2)
$("#Sites").multiselect();
指向具有id
'网站'的元素。但是,您的select元素上没有id。所以改变
<select data-bind="text: Sites" title="Sites" multiple="multiple" ></select>
进入<select data-bind="text: Sites" id="Sites" title="Sites" multiple="multiple" ></select>
,我觉得你很高兴。