Joss Posted January 24, 2013 Posted January 24, 2013 Hi there JQuery shaped people! I need to prepend something to an element on the page list, but because of the way it is working, I need to check whether it has already been prepended! So This is what I am starting with: <li class="PageListActionEdit"> <a href="/siteadmin/page/edit/?id=1">Edit</a> </li> And I need to end up with <li class="PageListActionEdit"> <a href="/siteadmin/page/edit/?id=1"><i class="icon-edit"></i>Edit</a> </li> Since this is part of the ajaxified page list, I can't simply do this: $('.PageListActionEdit a').prepend(' <i class="icon-edit"></i> '); Because it will just add another one on every time I click a page. I assume this is probably using either .not() or .has() to make sure a particular version has the Icon, and if so, doesn't prepend it, but I cant get it working! Help! Joss
diogo Posted January 24, 2013 Posted January 24, 2013 Hi again joss try this: $('.PageListActionEdit a').text(' <i class="icon-edit"></i> ');
Joss Posted January 24, 2013 Author Posted January 24, 2013 Hi Diogo - I thought you had gone home! All that does is print <i class="icon-edit"></i> (As in you can actually see it) and replace the "Edit", though at least it does not duplicate itself all over the place I have just tried html instead, and that is better, but I need to rescue the original text
diogo Posted January 24, 2013 Posted January 24, 2013 I'm sorry Joss, I meant $('.PageListActionEdit a').html(' <i class="icon-edit"></i>Edit ');
Joss Posted January 24, 2013 Author Posted January 24, 2013 haha I don't actually need the span or the </a> - what I was looking for is whether the word "edit" needed to be expressed in a special way for language translation purposes.
diogo Posted January 24, 2013 Posted January 24, 2013 the span was a present from the forum editor, I don't have anything to do with it. The a was my mistake when I copied the code... I will edit it
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now