在Asp.Net MVC JQuery用户界面日期选择 [英] JQuery UI datepicker in Asp.Net MVC

查看:110
本文介绍了在Asp.Net MVC JQuery用户界面日期选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试使用一些对一个Asp.Net MVC网站JQuery用户界面的小部件没有运气。

I have tried to use some of the widgets in JQuery UI on an Asp.Net MVC site without luck.

例如从 jQuery UI的基本日期选择器 - 功能演示的。

我创建了一个简单的MVC项目,并加入了的Site.Master脚本引用这样的:

I have created a simple MVC project and added the script references in Site.Master like this:

<script src="../../Scripts/jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-personalized-1.5.3.min.js" type="text/javascript"></script>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="../../Content/ui.datepicker.css" rel="stylesheet" type="text/css" />"

在Index.aspx的文件我已清除所有默认的内容,并添加以下内容:

In the Index.aspx file I have cleared all default content and added the following:

<script type="text/javascript">
    $("#basics").datepicker();     
</script>  
<input type="text" size="10" value="click here" id="basics"/>

jQuery核心工作正常。任何线索?

The core jQuery works fine. Any clues?

推荐答案

请确保在加载后DOM的初始化叫做:

Make sure your initializer is called after the DOM is loaded:

$(document).ready(function() {
    $("#basics").datepicker();
});

jQuery的ready事件

通过使用这种方法,你的绑定
  函数将被调用的瞬间
  在DOM是随时可以阅读和
  操纵,这是当为99.99%
  所有的JavaScript code需要运行。

By using this method, your bound function will be called the instant the DOM is ready to be read and manipulated, which is when 99.99% of all JavaScript code needs to run.

这篇关于在Asp.Net MVC JQuery用户界面日期选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆