excid3 / simple_calendar

A wonderfully simple calendar gem for Rails
http://excid3.github.io/simple_calendar
MIT License
1.58k stars 268 forks source link

AJAX previous and next link still relaod the full page #246

Closed AndresCarrasquilla96 closed 3 years ago

AndresCarrasquilla96 commented 4 years ago

Hello, I'm asking this question on the repo since it has more activity than the other one.

The thing is, I have a page with several tabs, one of them is for a calendar view:

At the index: index html erb

Helper: helper

Calendar partial: partial

And the js: index js erb

But it keeps on reloading the whole page, please help.

excid3 commented 4 years ago

Make sure your Rails UJS javascript is running so the links are submitted as JS requests.

AndresCarrasquilla96 commented 3 years ago

How can I check that? I recently updated the app to Rails 5.2.0 which is supposed to include rails-ujs. The manifest looks like this: imagen

Side-note: Are there any plans of adding an on-click event to the calendar cells or is there a way to do that?

excid3 commented 3 years ago

Looks like you're on an older app with jquery_ujs. Same thing should apply there. It's been so long that I don't remember if you need to do anything more than require jquery_ujs

I would use Stimulus JS to add events to the calendar cells. You're in an older app it looks like, so you may not have Webpacker. In that case, you can add click events with jQuery or whatever. The cells are td's in the calendar table, so you'd just select those.

And you can install the views into your app if you want to add customize it even more. Instructions are in the readme for that.

AndresCarrasquilla96 commented 3 years ago

What I noticed is that the data-remote: true attribute is not being added, apart from that I think everything else should be fine.

edit: I actually tried manually editing the HTML from the browser and added that attribute and it did load the calendar through Ajax, the problem is that the attribute is not being added in the helper. Do you have any idea why that might be happening?

And thank you for the suggestions.