javascript - RoR app utilizing bootstrap-datepicker-rails to update a timespan -
i'm still new ror, , i'm working ror application else started with. future reference, anytime name of application mentioned, put ...
in place. there's option request timespan defined as:
timespan_array = [ { display_value: "today", date: 1.day },{ display_value: "one week", date: 1.week },{ display_value: "two weeks", date: 2.weeks },{ display_value: "one month", date: 4.weeks },{ display_value: "three months", date: 12.weeks },{ display_value: "six months", date: 24.weeks },{ display_value: "all time", date: 520.weeks } ]
however, implement datepicker users can select specific days range. found bootstrap-datepicker-rails, , seemed sort of looking for. have basics set up:
app/assets/javascripts/.../application.js
:
//= require jquery //= require jquery_ujs //= require select2 //= require hubstats/bootstrap //= require bootstrap-datepicker //= require_tree . $(document).ready( function() { settimespan() }); $(document).on("focus", "[data-behaviour~='datepicker']", function(e){ $(this).datepicker({ "format": "yyyy-mm-dd", "weekstart": 1, "autoclose": true, "todayhighlight": true}) }); function settimespan() { var index = readcookie("..._index") || 2; var timer = document.getelementbyid("time-select"); timer.selectedindex = index; timer.onchange = function() { createcookie("..._index",this.selectedindex,1); window.location.reload(); }; }; function createcookie(name,value,days) { if (days) { var date = new date(); date.settime(date.gettime()+(days*24*60*60*1000)); var expires = "; expires="+date.togmtstring(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }; function readcookie(name) { var nameeq = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charat(0)==' ') c = c.substring(1,c.length); if (c.indexof(nameeq) == 0) return c.substring(nameeq.length,c.length); } return null; }; function erasecookie(name) { createcookie(name,"",-1); };
app/assets/stylesheets/.../application.css
:
*= require_self *= require hubstats/bootstrap *= require select2 *= require select2-bootstrap *= require bootstrap-datepicker *= require_tree .
app/views/.../partials/_header.html.erb
:
<div class="input-daterange"> <input type="text" class="input-small" data-behaviour="datepicker" id="start" placeholder="start date"/> <input type="text" class="input-small" data-behaviour="datepicker" id="end" placeholder="end date"/> </div>
gemfile
:
gem "jquery-rails" gem "mysql2" gem "bootstrap-datepicker-rails"
and of this, datepicker show in header (although that's not final location), , when select day, appear in text box.
however, when comes using datepicker javascript, i'm puzzled @ how make application recognize when date has been selected, save selected dates selected date range, , how update timespan include selected date range. still want users able use timespan, have option of picking specific date range.
i've read/considered using ton of links, including:
https://github.com/nerian/bootstrap-datepicker-rails
https://github.com/eternicode/bootstrap-datepicker
https://github.com/albertopq/jquery_datepicker
https://github.com/zpaulovics/datetimepicker-rails
https://github.com/zpaulovics/datetimedemo
https://github.com/aliibrahim/foundation-datetimepicker-rails
https://github.com/eonasdan/bootstrap-datetimepicker
https://stackoverflow.com/questions/28749408/fill-in-start-date-end-date-from-button-selection-bootstrap-datepicker
https://stackoverflow.com/questions/17009354/detect-change-to-selected-date-with-bootstrap-datepicker
http://stackoverflow.com/questions/15452617/bootstrap-datepicker-not-working-in-rails-3
http://stackoverflow.com/questions/15405703/rails-simple-form-bootstrap-and-datepicker
http://stackoverflow.com/questions/15405703/rails-simple-form-bootstrap-and-datepicker
http://stackoverflow.com/questions/28678834/using-bootstrap-datepicker-setdate-in-rails
http://stackoverflow.com/questions/29024983/rails-bootstrap-datepicker-not-working
http://stackoverflow.com/questions/19346781/how-to-retrieve-a-range-from-bootstrap-datepicker-rails
http://stackoverflow.com/questions/13867394/bootstrap-datepicker-rails-select-date-will-not-persist
http://stackoverflow.com/questions/12928918/how-to-setup-bootstrap-datepicker-rails
http://stackoverflow.com/questions/20464442/bootstrap-datepicker-rails-not-working-via-simple-form-with-bootstrap-modal
http://stackoverflow.com/questions/25450427/rails-bootstrap-datepicker-rails-not-working
https://groups.google.com/forum/#!forum/bootstrap-datepicker
https://learningnewtricks.wordpress.com/2013/07/03/bootstrap-date-picker-on-rails-so-simple/
http://bootstrap-datepicker.readthedocs.org/en/latest/index.html
http://stackoverflow.com/questions/19515053/bootstrap-datepicker-rails-on-rails4
http://jakoblaegdsmand.com/blog/2012/05/rails-datetime-picker/
http://www.davehulihan.com/bootstrap-datetimepicker-and-rails/
http://stackoverflow.com/questions/16351019/datetime-picker-in-ruby-on-rails
http://www.arubystory.com/2013/12/tutorial-creating-simple-todo.html
i know question seems specific project, , is, i'm sure i'm not 1 wants add option of datepicker selected time range.
any , greatly appreciated. if there questions, please feel free ask, , if have resources helped learn or understand in more detail, please link them.
Comments
Post a Comment