jQuery .load() function is failing in firefox 3.6.10
I'm a bit of a newbie, so excuse me if this script is rudimentary.
I'm trying to use jQuery's .load() function to load the next or previous month of an event calendar on an expressionengine site that I have built. The following script works in Chrome, Safari, IE, and Firefox 4 beta, but it fails in FF 3.6.10:
$('th a.right, th a.left, th a.center').click(function() {
var navMonth = $(this).attr("title");
$('#calendar').html('<p style="padding: 102px 120px;"><img src="http://dashboardco-op.org/images/infra/ajax-loader.gif" /></p>');
$('#calendar').load(navMonth);
});
And here's the html:
<th colspan="1"><a id="mc_prev_month" class="icon left" title="{path='live/calendar'}{prev_month format="%Y/%m"}/">←</a></th>
<th colspan="5"><a class="center" title="{path='live/calendar'}{next_month fo开发者_StackOverflowrmat="%Y/%m"}/">{month format="%F %Y"}</a></th>
<th colspan="1"><a id="mc_next_month" class="icon right" title="{path='live/calendar'}{next_month format="%Y/%m"}/">→</a></th>
I'm using the 'title' attribute, because .load() doesn't overwrite the 'href'-- therefore the pages load in a new page rather than asynchronously.
Thanks.
Not sure why it might have an issue with a particular browser, but I do think there is a slightly cleaner way to do what your going for. Take a look at this function in jQuery to cancel the opening of a new page on anchor click: preventDefault()
With this, you could put the path in the href tag, if for no other reason than it would probably make the markup look cleaner. Other than that, the only other things that come to mind are perhaps the anchor needs href attribute (I don't think this is the case?) or perhaps FF 3.6 handles the title attribute differently?
精彩评论