Title: javascript conflict with wp favorite posts plugin
Last modified: August 30, 2016

---

# javascript conflict with wp favorite posts plugin

 *  [Becki Beckmann](https://wordpress.org/support/users/becki/)
 * (@becki)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/javascript-conflict-with-wp-favorite-posts-plugin/)
 * hi there spacious team,
 * first, thanks really, really a lot for such a nice and free available theme. 
   this theme is really awesome and i do like it a lot, especially as you created
   your theme functions via function_exists() call, which makes it very easy to 
   overwrite in a child theme. thanks a lot, guys 😉
 * but i found an issue when using your theme with the WP favorite posts plugin
 * [https://wordpress.org/plugins/wp-favorite-posts/](https://wordpress.org/plugins/wp-favorite-posts/)
 * the wp favorite post plugin does some jquery ajax calls when marking posts as
   favorite posts
 * not sure which javascript is not properly done? but if i remove the navigation.
   js spacious theme file, then wp favorite posts ajax call can do its thing.
 * i did have a look and figured out that navigation.js is doing something they 
   call a self invoking function
 *     ```
       ( function() {
           // do navigation stuff
       } )();
       ```
   
 * and this self invoking function causes trouble with the ajax calls from the wp
   favorite post plugin, which was quite annoying for me and took me a while to 
   figure that one out.
 * so i removed the self invoking function and put all that javascript stuff into
   a jquery document ready thing, like so:
 *     ```
       jQuery(document).ready( function($) {
       	// do navigation stuff
       });
       ```
   
 * and the conflict is finally gone and i can mark posts as favorite again 😉 but
   i’m actually really not sure if this is ok? or if it will cause further problems?
   as i’m really no javascript guru 😉
 * the jquery code from the wp favorite post plugin goes as this:
 *     ```
       jQuery(document).ready( function($) {
           $('.wpfp-link').live('click', function() {
               dhis = $(this);
               wpfp_do_js( dhis, 1 );
               // for favorite post listing page
               if (dhis.hasClass('remove-parent')) {
                   dhis.parent("li").fadeOut();
               }
               return false;
           });
       });
   
       function wpfp_do_js( dhis, doAjax ) {
           loadingImg = dhis.prev();
           loadingImg.show();
           beforeImg = dhis.prev().prev();
           beforeImg.hide();
           url = document.location.href.split('#')[0];
           params = dhis.attr('href').replace('?', '') + '&ajax=1';
           if ( doAjax ) {
               jQuery.get(url, params, function(data) {
                       dhis.parent().html(data);
                       if(typeof wpfp_after_ajax == 'function') {
                           wpfp_after_ajax( dhis ); // use this like a wp action.
                       }
                       loadingImg.hide();
                   }
               );
           }
       }
       ```
   
 * what are your thoughts on my changes? is it ok? or will it cause trouble? or 
   is their a better way to solve this conflict?
 * thanks again for the spacious theme! you guys are awesome 😉
 * greetings
    becki

The topic ‘javascript conflict with wp favorite posts plugin’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/spacious/1.9.12/screenshot.jpg)
 * Spacious
 * [Support Threads](https://wordpress.org/support/theme/spacious/)
 * [Active Topics](https://wordpress.org/support/theme/spacious/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/spacious/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/spacious/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Becki Beckmann](https://wordpress.org/support/users/becki/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/javascript-conflict-with-wp-favorite-posts-plugin/)
 * Status: not resolved