Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:58:34+00:00 2026-06-01T01:58:34+00:00

will do my best to explain. Very new to jQuery so hope makes sense.

  • 0

will do my best to explain. Very new to jQuery so hope makes sense.

I am using a Favourites add-on for Expression Engine that allows me to mark an entry as a favourite, or a private favourite. (one or the other) so I’m utilising the private function as a mean to bookmark.
You mark items as favourites by means of a hyperlink which registers it when clicked and similarly when removing.

I am displaying these links and making them show/hide the other links with the help of jQuery.

Heres is my current jQuery code:

// favourites adding and removing
jQuery(function(jQuery) { // Shorthand for jQuery(document).ready(function($) {
  jQuery('a.mark').live('click', function() {
        var self = this;
        jQuery.get(self.href, {theID: self.id.substring(3)}, function(data) {
              jQuery(self).html('A Favorite').toggleClass('mark marked').
                    closest('li').prevAll('li:has(a.bookmarks)').hide(300);
        });
        return false;
  });
  jQuery('a.marked').live('mouseover', function() {
        jQuery(this).html('Remove Favourite');
  }).live('mouseout', function() {
        jQuery(this).html('A Favourite');
  }).live('click', function() {
        var self = this;
        jQuery.get(self.href, {theID: self.id.substring(3)}, function(data) {
              jQuery(self).html('Save as a Favourite').toggleClass('marked mark').
                    closest('li').prevAll('li:has(a.bookmarks)').show(300);
        });
        return false;
  });
});

// bookmarks adding and removing
jQuery(function(jQuery) { // Shorthand for jQuery(document).ready(function($) {
  jQuery('a.bookmarks').live('click', function() {
        var self = this;
        jQuery.get(self.href, {theID: self.id.substring(3)}, function(data) {
              jQuery(self).html('A Bookmark').toggleClass('bookmark bookmarks').
               closest('li').nextAll('li:has(a.mark)').hide(300); // Or .hide(300);
        });
        return false;
  });
  jQuery('a.bookmark').live('mouseover', function() {
        jQuery(this).html('Remove Bookmark');
  }).live('mouseout', function() {
        jQuery(this).html('A Bookmark');
  }).live('click', function() {
        var self = this;
        jQuery.get(self.href, {theID: self.id.substring(3)}, function(data) {
              jQuery(self).html('Save as a Bookmark').toggleClass('bookmark bookmarks').
                    closest('li').nextAll('li:has(a.mark)').show(300); // Or .hide(300);
        });
        return false;
  });
});

Now this works almost exactly as it should do, except I have to refresh the page once a “add” link is clicked, in order for it to generate the correct delete links.

The type of behaviour I need is basically to refresh the section once the link has been clicked, making everything register as if the page had been refreshed.

Does that make sense? i hope so! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:58:35+00:00Added an answer on June 1, 2026 at 1:58 am

    Right just thought i’d finish this one up. Finally got it working!

    The jist of it is….

    In order to change the href as well as the class, I had to manually add a delete link to my code

    // favourites adding and removing
    jQuery(function (jQuery) {
    jQuery('a.fav_me').live('click', function () {
        var self = this;
        jQuery.get(self.href, {
            theID: self.id.substring(3)
        }, function (data) {
            jQuery(self).html('A Favourite').toggleClass('fav_me fav_delete');
        });
        return false;
    });
    jQuery('a.fav_delete').live('mouseover', function () {
        var entryID = jQuery(this).attr("rel");
        jQuery(this).html('Remove Favourite').attr('href',     'http://domain.com/forms/favourite-add/' + entryID + '/delete/');
    }).live('mouseout', function () {
        jQuery(this).html('A Favourite');
    }).live('click', function () {
        var entryID = jQuery(this).attr("rel");
        var self = this;
        jQuery.get(self.href, {
            theID: self.id.substring(3)
        }, function (data) {
            jQuery(self).html('Save as a Favourite').toggleClass('fav_delete fav_me').attr('href', 'http://domain.com/forms/favourite-add/' + entryID);
        });
        return false;
    });
    });
    

    and then my template looked like this…

    {if not_saved}
                            <li><a class="fav_me" id="{entry_id}" href="{path=forms/favourite-add}/{entry_id}" rel="{entry_id}">Save as a Favourite</a></li>
                            {/if}<!--not saved-->
                            {if saved}
                            <li><a class="fav_delete" id="{entry_id}" href="{path=forms/favourite-add}/{entry_id}/delete/" rel="{entry_id}" >A Favourite</a></li>
                            {/if}
    

    Thats what I had to put in order to get it to work. I also decided against having fav and bookmarks, so i then had no need to show or hide the other bookmark/fav. Thanks for the help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to database, I will try my best to explain myself
Ok, I'm very new to PHP. I will try my best to explain my
The title is not very descriptive, but I will do my best to explain
I will try my best to explain this. I have an application that show
I am new to iOS development. I will try my best to explain my
I will do my best to explain this. Hopefully my notes in script will
I'm going to try to explain this best I can I will provide more
I would like to create a calculated member, (or whatever is best) that will
What is the best way to write a function (or something DSLish) that will
I will do my best to explain my headache here. I've got 2 generic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.