• 0
Sign in to follow this  
Followers 0

jQuery blown up front end editor


Question

Posted · Report post

So I have been trying to add a simple bit of jQuery into the page, it needs to go at the bottom of the body and not the header.
 
I initially added it to the custom code (header) section but that locked up the front end editor. I then found that you can remove it by going to the dashboard/pagelines/DMS Tools/DMS Header Scripts Fallback. I removed it and then the editor worked again.
 
I then tried adding a textbox to the footer and adding the code, now the editor is fully locked and I cannot do anything. I'm using Nicks base theme V1.2 and this is the simple bit of code I entered:

 

<script>
        jQuery(document).ready(function() {
            jQuery("#portfolio-list").filterable();
        });
</script>

 

Any ideas how to fix this other than making a child theme again and also how woul i go about adding this bit of jQuery onto a page BOT in the header?

 

Cheers

Share this post


Link to post
Share on other sites

9 answers to this question

  • 0

Posted · Report post

So after deleting the child theme and reactivating DMS, the problem was still there. I then deleted DMS completely and reinstalled but the issue of not having the front end editor is still there. What next?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I managed to fix this by visiting the default set up "Sample Page", the editor was now working so I used the "Undo all" option and saved. Then went back to the homepage and the editor was working again.

 

I guess I should add the jquery to the footer.php and avoid adding any into the page.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

No you shouldn't edit core files, by doing so, you void all support and will most likely break DMS. I recommend you use a hook - http://docs.pagelines.com/advanced/hooks
pagelines_before_footer

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

footer.php in the child theme I created not the core files. Hence me creating a child theme to not mess with the core files.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

If it's your own child theme, you can still break DMS by adding that to the footer.php of child theme.  Danny's correct. A hook would be much more appropriate in the child theme's functions.php.  That's what it's there for.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

It's all sorted, you can close this.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Actually maybe its a good thing this question is not closed because I have the same issue again. I followed your advice on using the hooks and created this in functions.php:

 

/*--- ADD JQUERY TO FOOTER ---*/
function filterable() {
    if (is_front_page()) {
    echo '<script>
        jQuery(document).ready(function() {
            jQuery("#portfolio-list").filterable();
        });
</script>';
    }
}
add_action('wp_footer', 'filterable');

 

Am I doing this incorrectly? Its adding the script to the footer and working but again its making the visual editor stop working..

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I forgot to add that I'm also enqueing the script before hand:

/*--- ENQUEUE SCRIPTS ---*/
function enqueue_filterable() {
if (is_front_page()) {
wp_register_script( 'filterable', esc_url( trailingslashit( get_stylesheet_directory_uri() ) . 'js/filterable.js' ), array(), false, false );
wp_enqueue_script( 'filterable' );}
}  
add_action('wp_enqueue_scripts', 'enqueue_filterable');

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

So to advance on my previous problems/questions I have added:

 

/*--- ADD JQUERY TO FOOTER ---*/
function filterable() {
    if (is_front_page()) {
    echo '<script>
        jQuery(document).ready(function() {
            jQuery("#portfolio-list").filterable();
        });
</script>';
    }
}
add_action('pagelines_before_footer', 'filterable');

 

Why didn't I look at the "pagelines_before_footer" bit you mentioned earlier.....

 

I'm not sure if this is still the correct way to do it but anyway It all seems to be working nice now.

 

Is there a page/doc/list anywhere of the available pagelines hooks? The current docs link is very minimal and there was no mention of the "pagelines_before_footer" hook in those docs so I would never have worked that out.

 

Thanks for the help

Stuart

 

P.S I wish there was an EDIT post option in here so that I dont have to keep adding more and more.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0