Using datepicker within haml

别来无恙 提交于 2019-12-11 17:14:37

问题


I am sorta new to using datepicker within haml and was hoping to get some guidance. I have included a javascript with a datepicker within my main.html along with two date fields. Unfortunately, when I try to test the following code I get nothing. Any idea what I might be overlooking? Any help will be greatly appricated.

#content

%h3
  Please enter the following information:
=form('/search', :post)
=input(:id, :report_id, class: "formbox")
=input(:date, :start_date, class: "formbox")
=input(:date, :end_date, class: "formbox")
=submit('Submit', class: "button")

:javascript
  $(function() {
    $( "#start_date, #end_date" ).datepicker({format: 'yyyy-mm-dd'});
  });

回答1:


In HAML, the way you indent is key to your code working correctly. You need to change your indentation as follows:

%h3
  Please enter the following information:
= form('/search', :post)
  = input(:id, :report_id, class: "formbox")
  = input(:date, :start_date, class: "formbox")
  = input(:date, :end_date, class: "formbox")
  = submit('Submit', class: "button")

:javascript
  $(function() {
    $( "#start_date, #end_date" ).datepicker({format: 'yyyy-mm-dd'});
  });


来源:https://stackoverflow.com/questions/24259780/using-datepicker-within-haml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!