Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calendar schedule

I have a calendar type of schedule, whereby you can book slots. However I am attempting to create a 'next month' button so that it generates the following month. I have done the following:

<button id="nextmonth">Next month</button>


<script>
$('#nextmonth').on('click', function(e) {
   $.get('/rota_days/show.json?mon=12').success(function(data) 
    { 

    /* display response */ 


    });
});
</scirpt>  

Alternatively I did trying doing the following - <%= link_to 'Next Month', rota_days_path(:month => 12) %> however I this is not working for me.


1 Answers

If you have a regular template at /rota_days/show.js that you want rendered, then you should be able to call it like so:

= link_to 'Next Month', rota_days_path(:month => m), :remote => true

Note that via Rails UJS, link_to and button_to both support the method option which would allow you to specify get, post, put, delete.

Make sure your routes support the route you're trying to link to, and that your controller returns the right response. If you still have problems please post your controller and template.

like image 160
Andrew Avatar answered Mar 26 '26 11:03

Andrew