So I’m not really sure how to explain this, so I will just provide an example. I’m using fullCalendar
jquery calendar to populate events in a calendar on my page. fullCalendar
has a method called ‘eventClick’ which you can then run some code.
Basically I’m trying to go to a page on my site (the event page) when clicked and passing it the URL like so:
$('#calendar').fullCalendar({
events:array,
eventClick: function(event) {
if( event.url ) {
window.open(event.url);
return false;
}
}
});
event.url is a string that I’m pulling in from WordPress and is displayed like so:
http://sitedomain.com/?post_type=events&p=340
The Problem
When I click on an event, the URL gets encoded differently and displays like this:
http://sitedomain.com/?post_type=events&p=340
where &
gets replaced with &
which then obviously doesn’t go to the correct page on my site. I rewrote my click method like so but I still get the same results –
$('#calendar').fullCalendar({
events:array,
eventClick: function(event) {
var page = event.url;
page = page.replace('&', '&');
if( page ) {
window.open(page);
return false;
}
}
});
Anyone have a solution?
Thanks,
Well I feel stupid.
I guess I failed to mention that I was using
window.location.href
whereas in my example question I was usingwindow.open
.The problem was that I was getting the syntax incorrect for
window.location.href
using it like so:instead of
Reminder to get your syntax right and then things will work like you think they are suppose to… 🙂 Thanks for the help all.