J'ai une application, je construis avec Backbone et Marionette, je pense que cela est une fonction jQuery ou quelque chose comme ça, je trouve ce code sur marionette Voir
$('#publicdate',this.el)[0]
Y at-il un similaire avec ce code dans le plus pur Javascript ? J'ai essayé ce code
document.getElementById('date1')
this.getElementById('date1')
mais ne fonctionne pas
Voici le code complet:
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"
})
})
Merci à l'avance!
Le getElementById aurait dû fonctionner. Peut-être que vous avez utilisé le mauvais identifiant. – inf3rno