Premisse: I have scant knowledge of javaScript.
In a rails layout, the following script functions:
<script>
$(function() {
$( "#date_available_dal" ).datepicker({dateFormat: 'yy-mm-dd', showButtonPanel: true});
$( "#date_available_al" ).datepicker({dateFormat: 'yy-mm-dd', showButtonPanel: true});
});
</script>
But if I place the same code, while stripping the open and close script tags, in a .js file within the assets/javascripts file, the browser loads the file, but [as Curly would say] nothing happens.
I've experienced this on many an occasion & it impedes me from using the pipeline properly. What is rails doing in the background that may change this script's behaviour?
In the same line of thinking, if I were to append the locale given an application method
def set_locale
if user_signed_in?
I18n.locale = current_user.idioma.code.downcase
else
I18n.locale = params[:locale] || I18n.default_locale
end
end
to
datepicker({dateFormat: 'yy-mm-dd', regional[ #{set_locale} ]
how would this code be handled between the stacks?
Update
Presently in development mode, the browser is receiving the file with the following:
$(function() {
$( "#date_available_dal" ).datepicker({dateFormat: 'yy-mm-dd', minDate: 0, numberOfMonths: 3, showButtonPanel: true});
$( "#date_available_al" ).datepicker({dateFormat: 'yy-mm-dd', minDate: 1, numberOfMonths: 3, showButtonPanel: true});
});