我有一個應用程序,我建立與骨幹網和提線木偶,我覺得這是一個jQuery函數或類似的東西,我發現木偶查看該代碼
$('#publicdate',this.el)[0]
是否有與純JavaScript代碼類似?我曾嘗試這個代碼
document.getElementById('date1')
this.getElementById('date1')
但不工作
這裏全碼:
programming.module("Program.Chart", function(Chart, programming, Backbone, Marionette, $, _){
Chart.chartT = Marionette.ItemView.extend({
template : "#row",
tagName : "tr"
})
Chart.chartV = Marionette.CompositeView.extend({
childView : Chart.chartT,
childViewContainer : "tbody#detail",
template : "#chart",
onRender : function(){
//DatePicker Range
var
startDate,
endDate,
updateStartDate = function() {
startPicker.setStartRange(startDate);
endPicker.setStartRange(startDate);
endPicker.setMinDate(startDate);
},
updateEndDate = function() {
startPicker.setEndRange(endDate);
startPicker.setMaxDate(endDate);
endPicker.setEndRange(endDate);
},
startPicker = new Pikaday({
field: $('#date1',this.el)[0],
minDate: new Date(),
maxDate: new Date(2020, 12, 31),
onSelect: function() {
startDate = this.getDate();
updateStartDate();
}
}),
endPicker = new Pikaday({
field: $('#date2',this.el)[0],
minDate: new Date(),
maxDate: new Date(2020, 12, 31),
onSelect: function() {
endDate = this.getDate();
updateEndDate();
}
}),
_startDate = startPicker.getDate(),
_endDate = endPicker.getDate();
if (_startDate) {
startDate = _startDate;
updateStartDate();
}
if (_endDate) {
endDate = _endDate;
updateEndDate();
}
var selectdate = $('#publicdate',this.el)[0];
selectdate.addEventListener("change",function(){
alert("Changed")
})
//Chart JS
var dataChart = programming.request("data:entities");
console.log(dataChart.models)
var labels = ['12/08/2016','13/08/2016','16/08/2016']
var series = [[100,210,311],[49,10,7]]
var data = {
labels : labels,
series : series
}
var option = {
showArea : true,
lineSmooth : false,
chartPadding : {
bottom:30,
top:30
},
axisX : {
showGrid:false
},
axisY : {
},
plugins : [
Chartist.plugins.ctAxisTitle({
axisX: {
axisTitle: 'Tanggal',
axisClass: 'ct-axis-title',
offset: {
x: 0,
y: 50
},
textAnchor: 'middle'
},
axisY: {
axisTitle: 'Jumlah Penjualan',
axisClass: 'ct-axis-title',
offset: {
x: 0,
y: 0
},
textAnchor: 'middle',
flipTitle: false
}
}),
Chartist.plugins.ctPointLabels({
textAnchor : "middle"
})
]
}
new Chartist.Line($('.statistic',this.el)[0],data,option)
}
})
Chart.notfound = Marionette.ItemView.extend({
template : "#notfound"
})
})
提前感謝!
getElementById應該已經工作。也許你使用了錯誤的ID。 – inf3rno