What is meaning of typedef $ in following source code. I have read from this link.
typeof allows the identifier to never have been declared before. So it's safer in that regard:
But here they are using if (typeof $ !== 'undefined')
, what is meaning of $
here.
I copied following code from this link
<script type="text/javascript">
if (typeof horizon.d3_line_chart !== 'undefined') {
//alert("test1");
//When first time It give alert means it is defiend
horizon.d3_line_chart.init("div[data-chart-type='line_chart']",
{'auto_resize': true});
}
if (typeof $ !== 'undefined') {
//alert("alert2");
/*
We first time we run resource usage, then It will show alert, and date options are not showing. So means first time It hides the date options. Means '$' varaible is defined.
*/
show_hide_datepickers();
} else {
addHorizonLoadEvent(function() {
show_hide_datepickers();
});
}
function show_hide_datepickers() {
$("#date_options").change(function(evt) {
// Enhancing behaviour of selectbox, on 'other' value selected, I don't
// want to refresh, but show hide the date fields
if ($(this).find("option:selected").val() == "other"){
evt.stopPropagation();
$("#date_from input, #date_to input").val('');
$("#date_from, #date_to").show();
} else {
$("#date_from, #date_to").hide();
}
});
if ($("#date_options").find("option:selected").val() == "other"){
$("#date_from, #date_to").show();
} else {
$("#date_from, #date_to").hide();
}
}
</script>