Ruby on Rails Sunday, March 6, 2016

On Sun, Mar 6, 2016 at 5:59 PM, Donald Ziesig <donald@ziesig.org> wrote:
On 03/06/2016 05:22 PM, Colin Law wrote:
On 6 March 2016 at 21:45, Donald Ziesig <donald@ziesig.org> wrote:
...
This is the whole thing (including alerts to let me know when clicks are
handled):

     <script>
       var AUTH_TOKEN = $('meta[name=csrf-token]').attr('content');
       $(document).ready(function()
       {
         $('#calendar').fullCalendar(
         {
           minTime: "08:00:00",
           maxTime: "20:00:00",
           eventRender: function (event, element) {
             element.click(function() {});
           },
           eventClick: function(calEvent, jsEvent, view) {
             alert('Clicked on: ' + calEvent.format());
           },
           dayClick: function(date, jsEvent, view) {
             alert('You Clicked on: ' + date.format());
             // $.post('/lockout/'+date.format())
             $.ajax({
               url: '/lockout/'+date.format(),
               type: 'post',
               dataType: "html",
               data: "&authenticity_token="+AUTH_TOKEN,
               success: function(){alert('SUCCESS');},
You are not doing anything with the response that comes back on
success.  That should contain the data you are rendering in the
server.

Colin

It always pays to have experts look at your code!

Changing:

success: function(){alert('SUCCESS');}

to:

success: function(){window.location.reload(true);}

made the difference.  It works now.

Thank you Colin,

Don

I'm rather curious, if what you want is a full page reload at that point, why you're bothering using AJAX?

 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHUC_t_xK7%2Bjy-NoUigWeV-xj3oE9o%2BeN3Rh-2VQxfc00R_VYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment