That seems to have done the trick, most of my problems now are down to design issues and just need cleaning up.
Thanks folks, Tane On 4/17/07, Kelvin Luck <[EMAIL PROTECTED]> wrote:
You can use the .is() method. It would look something like this on your code: function hijackLinks(root) { $('a',root).click(function(){ $this = $(this); if ($this.is(".admin-link")) { // If admin link, load into sub-admin area $('.admin-area').load(this.href,function(){ hijackLinks($('.content')); }); return false; } else if ($this.is(".no-ajax")) { // If no ajax link, ignore } else { // Normal content area link $('.content').load(this.href,function(){ hijackLinks($('.content')); }); return false; } }); } Hope that helps, Kelvin :) On Tue, 17 Apr 2007 11:02:07 +0100, digital spaghetti <[EMAIL PROTECTED]> wrote: > > Bahh, I've found a bug. In the code when I get type, I check to see > if type == "whatever". But it seems if my links have more than 1 > class, it fails. For example my code may have <a > href="/admin/posts/add" class="add admin-link">Add Post</a> - this is > ignored. > > Whats the best way to check to see if a link contains the class, > without doing a == selection on it? > > Tane > > On 4/17/07, digital spaghetti <[EMAIL PROTECTED]> wrote: >> Hi Sean, >> >> Thanks, that seems to have done the trick - although it broke the Tabs >> plugin I was using in my admin interface. I've created a workaround >> and this works perfectly: >> >> function hijackLinks(root) { >> $('a',root).click(function(){ >> var type = $(this).attr('class'); >> if (type == "admin-link") { >> // If admin link, load into sub-admin area >> $('.admin-area').load(this.href,function(){ >> hijackLinks($('.content')); }); >> return false; >> } else if (type == "no-ajax") { >> // If no ajax link, ignore >> } else { >> // Normal content area link >> $('.content').load(this.href,function(){ >> hijackLinks($('.content')); }); >> return false; >> } >> }); >> } >> >> $(document).ready(function() { >> hijackLinks(document); >> }); >> >> >> >> Tane