0

In my rails application, I have a single datepicker from bootstrap in the index of my events page.

<input type="text" name="datefilter" value="" />

<script type="text/javascript">
$(function() {

  $('input[name="datefilter"]').daterangepicker({
        singleDatePicker: true,
      locale: {
          cancelLabel: 'Clear'
      }
  });


  $('input[name="datefilter"]').on('cancel.daterangepicker', function(ev, picker) {
      $(this).val('');
  });

});
</script>

Once I select a date in the datepicker, I want to be able to list out all the events created that day based on the created_at attribute.

I'm assuming I will be using a function similar to

@events = Event.all.where(date_selected)

and then just looping through them

 <%@events.each do |e|%>
  <% e.name %>
.
.
.
etc
  <%end %>

but i am unsure how to define "date_selected" in bootstrap to be able to access all the events for that day based on their created_at attribute.

**In response to duplicate question: I am trying to understand how to select a date for an event in my function, not change an event in jquery. I would then like to list out all events created on the selected date.

MisterCal
  • 622
  • 2
  • 7
  • 22
  • Possible duplicate of [jQuery bootstrap-datetimepicker change event](http://stackoverflow.com/questions/31858920/jquery-bootstrap-datetimepicker-change-event) – benomatis Feb 09 '17 at 23:24
  • edited for clarification – MisterCal Feb 09 '17 at 23:33
  • "change" in this sense doesn't mean you want to change an event, it means you want to _listen_ to the change event, ie. you want to take action (eg. gather the selected value) _when_ tha change happens... – benomatis Feb 10 '17 at 06:00
  • I see, however this does not solve my problem. The datepicker they are using does not work on my rails application despite following the installation instuctions exactly. The datepicker that I am using will at least show up to my screen, i just need clarification on how to make use of the input. – MisterCal Feb 10 '17 at 10:59

0 Answers0