jquery - DateTime picker in Ruby on Rails -
i want add datetime picker on ror app.
add:
1. jquery-ui-timepicker-addon.js file in "assest/javascripts",
2. jquery-ui-timepicker-addon.css in "assest/stylesheets".
in .erb file, add this:
<html> <head> <%= javascript_include_tag "jquery-ui-timepicker-addon" %> <%= stylesheet_link_tag "jquery-ui-timepicker-addon" %> </head> <body> <script>$('#ngo').datetimepicker();</script> <input type="text" id="ngo" /> </body> </html>
but when run it. have following errors:
uncaught typeerror: cannot read property 'timepicker' of undefined jquery-ui-timepicker-addon.js:21 uncaught typeerror: cannot read property 'timepicker' of undefined jquery-ui-timepicker-addon.js:21 uncaught typeerror: object [object object] has no method 'datetimepicker'
any help?
link these script:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
or can download these script , add application directory (app/assets/javascripts/something.js or public/javascripts/something.js
)
and add <%= javascript_include_tag "something" %>
application layout.
after code html , js
html
<input type="text" class='tinytext' id="datepicker" name='time_from'>
javascript
<script type="text/javascript"> $(function () { $("#datepicker").datepicker({ dateformat:'mm/dd/yy' }); </script>
Comments
Post a Comment