点击图标打开jQuery UI Datepicker
On click of icon open jQuery UI Datepicker
在主干视图中,我在html
中有以下代码<input type="text" id="fromDate" name="fromDate"/><a id="cal">
<img src="img/calendar.gif"></a>
在view的js文件中,我有以下代码:
define(['jquery', 'underscore', 'backbone', 'text!views/page1/page1.tpl'], function($, _, Backbone, tmpl_page1View) {
var page1View = Backbone.View.extend({
// Setting the view's template property using the Underscore template method
template: _.template(tmpl_page1View),
// View constructor
initialize: function() {
self = this;
},
// View Event Handlers
events: {
"click #page2": "clickedPage2",
"click #cal":"calClicked"
},
// Renders the view's template to the UI
render: function() {
this.$el.html(this.template({data: this.templateData}));
// Maintains chainability
return this;
},
clickedPage2:function(){
window.location.href = "#page2"
},
calClicked:function(){
$("#fromDate").datepicker({
showOn: "button",
buttonImage: "img/calendar.gif",
buttonImageOnly: true
});
}
});
return page1View;
});
单击日历图标的事件,我想打开日期选择器,但它不工作。你能帮我解决这个问题吗?谢谢你。
您应该初始化日期选择器,例如在render
方法中,日期选择器将在单击按钮时自动打开,因此您根本不需要calClicked
。
var page1View = Backbone.View.extend({
// Setting the view's template property using the Underscore template method
template: _.template(tmpl_page1View),
// View constructor
initialize: function() {
self = this;
},
// View Event Handlers
events: {
"click #page2": "clickedPage2",
"click #cal":"calClicked"
},
// Renders the view's template to the UI
render: function() {
this.$el.html(this.template({data: this.templateData}));
// init datepicker
this.$("#fromDate").datepicker({
showOn: "button",
buttonImage: "img/calendar.gif",
buttonImageOnly: true
});
// Maintains chainability
return this;
},
clickedPage2:function(){
window.location.href = "#page2"
}
});
return page1View;
});
相关文章:
- jQuery UI自动完成突然停止工作
- Rails/JSON:如何将JSON用于jquery UI自动完成表单
- 停止jQuery UI滑块移动超过给定值
- Jquery UI自动完成无法工作
- jquery ui滑块上的滑块值
- jQuery UI可排序-多连接列表拖动
- 使用Jquery ui时滑块无法工作
- JQuery UI可拖动潜水与滚动棒到鼠标
- jQuery UI自动完成-修改问题
- JQuery UI日期选择器:在选择出发日期时自动弹出返回日期
- 阻止选项卡缓存jquery ui
- 将jQuery UI Timepicker Addon与React一起使用
- 如何在页面重新加载时显示jquery ui对话框
- jquery ui自动完成导致标头错误
- jquery UI draggable:UI.children不是一个函数
- 在JQuery UI Accordion Sortable中使用touchpunch无法正确使用touch
- Jquery UI对话框不会消失
- jQuery UI对话框错误,按钮导致HierarchyRequestError
- jQuery UI使用json文件自动完成
- 如何从内部销毁jQuery UI小部件's原型