【发布时间】:2010-05-26 01:08:39
【问题描述】:
我正在尝试将两个 jquery 插件文件添加到我的应用程序中。当用户触发我的 ajax 事件时,服务器将返回带有表单按钮的文本。当用户单击返回的文本内的表单按钮时,插件(一个 jquery 日历)将起作用。我相信我必须在返回文本而不是主页中添加链接才能让代码工作,但不知道如何做到这一点。我正在给出我的代码,需要您的专家意见。谢谢。
我的主页html
//required jquery plugins ...didn't work if I add them in the main application.
<script type="text/javascript" src="JS/date.js"></script>
<script type="text/javascript" src="JS/datePicker.js"></script>
<script type="text/javascript" src="JS/selectWeek.js"></script>
<div id="gameInfo">
//return text will be displayed here.
</div>
我返回的文本......其中的一部分......
<form>
<div id=returnDiv>
// the form input will be added here when a user clicks #addMatch button...
</div>
<tr>
<td><input type="button" id="addMatch" name="addMatch" value="Add Match"/> </td>
</tr>
</form>
我的 jquery
$("#addMatch").live('click', function(){
//the code below will create a calendar when a user click the link...I am not sure //where I should add my two jquery plugins link...
$("#returnDiv").html("<td><input type='text' size='6' class='date-pick dp-applied'"+ "name='date'><a style='color:white;' class='dp-choose-date' title='Choose Date'"+ "href='#'>Date</a></td>";
return false;
});
我希望我能很好地解释我的问题。 +1 任何回复...:D
【问题讨论】:
-
你的 html 格式不正确......我们可以看到用于创建日历的链接的 jQuery......
-
我只显示我的 html 的一部分。 jquery 插件文件非常长。不要以为我可以全部展示出来。
-
如果有人对插件感兴趣,我正在使用这个...kelvinluck.com/assets/jquery/datePicker/v2/demo