WordPress.org

Ready to get started?Download WordPress

Forums

Simple Mathjax
Live refresh with P2 theme? (1 post)

  1. adam98110
    Member
    Posted 3 months ago #

    Is there a way to configure this plugin so that it refreshes posts, as they are updated? I am using the P2 theme, which lets you make frontend posts, that are updated live via Ajax. But in order to get MathJax to display, you have to first refresh the entire page...

    I was able to hack together a solution by modifying the theme's p2.js file, changing this code segment:

    // Catch new posts submit
    $("#new_post").submit(function(trigger) {
    	if ( $( 'ul.ui-autocomplete' ).is( ':visible' ) )
    		return false;
    
    	p2.posts.submit(trigger);
    	trigger.preventDefault();
    });

    into this:

    // Catch new posts submit
    $("#new_post").submit(function(trigger) {
    	if ( $( 'ul.ui-autocomplete' ).is( ':visible' ) )
    		return false;
    
    	p2.posts.submit(trigger);
    	trigger.preventDefault();
    
    	/* Trigger MathJax refresh when new post is submitted */
    	$(document).ajaxComplete(function(){
    		MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
    	});
    });

    But perhaps there is a way to do this with the plugin's configuration instead? Also, this code refreshes the entire blog, not just the active post...

    Thanks,
    -Adam

    http://wordpress.org/plugins/simple-mathjax/

Reply

You must log in to post.

About this Plugin

About this Topic