Ruby on Rails Sunday, March 6, 2016

On 03/06/2016 07:41 PM, tamouse pontiki wrote:
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?

Because I don't know any other way to go from the fullcalendar javascript event to the server. :'(   .  If you have a better approach, please tell me how.  It is never too late to learn something new (I'm 73 years old and started programming in the late 1950's.  I've been learning a lot of new things since then ;-) ). 

I would really like to process the dayclick event on the server, prompt the user for a response, then reload the page.  That implies that I need to render html or json to do the prompting, then reload the page with data conditioned on the user's response.  So far I haven't been able to do that.

Thanks

Don

 
--
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