Support

Home Forums Event Espresso Premium Having trouble remove event link on calendar using jquery

Having trouble remove event link on calendar using jquery

Posted: December 7, 2015 at 2:27 pm


Linda Isarasakdi

December 7, 2015 at 2:27 pm

We have a public-facing calendar on which we want to remove the link to actual event page. I’ve got the jquery written to remove the href attribute from a.fc-event, but it won’t work. I’ve tried a window timeout to give the calendar some time to load, but even at 4 seconds, it’s not working.

I should add that the events in question are on the January 2016 calendar and it’s currently December 2015. I’m wondering if the timing issue is complicated by the loading of the next month screen…


Josh

  • Support Staff

December 7, 2015 at 4:53 pm

Hi Linda,

We can take a look at the code you’re trying to use and offer suggestions if you can post it in a pastebin or a gist and link to the code here.


Linda Isarasakdi

December 8, 2015 at 7:59 am

Thanks, Josh

http://pastebin.com/Ym8ig5Gm


Josh

  • Support Staff

December 8, 2015 at 10:25 am

Hi Linda,

Here are a few suggestions for how you can have a better time with removing those links: 1) Use JQuery in no-conflict mode and wrap in script tags. 2) Use PHP to conditionally load the script 3) Use the ajaxComplete() method so it waits for the Ajax request to complete. Here’s an example:

https://gist.github.com/joshfeck/40f648fb25fc90d8a25e


Linda Isarasakdi

December 8, 2015 at 10:51 am

Sorry, should have said that I pulled the code from inside a js file that runs on the site so the no-conflict mode is taken care of. I can make a special js that only runs on the calendar pages rather than using a conditional inside of the javascript. I’ll have a look at the Ajax shortly. Thanks so much!


Josh

  • Support Staff

December 8, 2015 at 12:51 pm

It could still work to be included in a file, and you would still use the ajaxComplete() method for event handling.


Linda Isarasakdi

December 9, 2015 at 9:31 am

Thanks Josh – that ajaxcomplete was the answer!

Slight changes I made to target the event href and to also switch the cursor so people didn’t think there was supposed to be a link there:

` <script>jQuery( document ).ajaxComplete(function() {
jQuery( ‘a.fc-event’ ).removeAttr(‘href’);
jQuery( ‘a.fc-event’ ).css(‘cursor’, ‘default’);
});</script>’


Josh

  • Support Staff

December 9, 2015 at 10:31 am

You will gain some performance if you select by the ID, it’s a lot faster than selecting by class.


Linda Isarasakdi

December 9, 2015 at 2:48 pm

I’ll try it again, Josh, but the reason I switched was that #espresso_calendar a
didn’t remove the link when I used the original javascript.


Linda Isarasakdi

December 9, 2015 at 2:53 pm

It’s working now, Josh – I think our server is doing some caching as I did a hard refresh first and then waited a couple of minutes and did it again.

Thanks so much!

So for anyone else, the final answer to our issue was:

` <script>jQuery( document ).ajaxComplete(function() {
jQuery( ‘#espresso_calendar a’ ).removeAttr(‘href’);
jQuery( ‘#espresso_calendar a’ ).css(‘cursor’, ‘default’);
});</script>’

The support post ‘Having trouble remove event link on calendar using jquery’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso