WordPress.org

Support

Support » Themes and Templates » [Resolved] Java script support on my Theme options page

[Resolved] Java script support on my Theme options page

  • Rakesh Raja
    Participant

    @rakeshraja

    Hi

    I am creating theme options page.. I want to use jquery tabs for sections .. I need to use following code.. but its not working in admin

    <script type="text/javascript">// <![CDATA[
    
    			$(document).ready(function () {
    				$('.wpgpanelmenu').tabify();
    			});
    
    			// ]]>
    </script>

    Any idea how can I run it? or any other way?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Jan Dembowski
    Volunteer Mod. & Brute Squad

    @jdembowski

    It may be how you are inserting the code. Have you reviewed this article?

    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Rakesh Raja
    Participant

    @rakeshraja

    That I have done already for actual .js files

    wp_enqueue_script( 'theme-options', get_template_directory_uri() . '/wpgpanel/js/jquery.js' );
    wp_enqueue_script( 'theme-options', get_template_directory_uri() . '/wpgpanel/js/jquery.tabify.js' ); ?>

    But to make tabs work.. I need to add above code directly in theme options file.. and its not working

    <script type="text/javascript">// <![CDATA[
    
    			$(document).ready(function () {
    				$('.wpgpanelmenu').tabify();
    			});
    
    			// ]]>
    </script>
    Rakesh Raja
    Participant

    @rakeshraja

    Here is solution, Now you can use any jQuery or javascript code in your theme options page

    Just make sure you add following action before you load your options page data..

    add_action('admin_print_scripts', 'my_admin_head_script');

    Right after it create functions we used above and add all your code and javascripts there.. thats it!

    <?php function my_admin_head_script() { ?>
    
    <script src="<?php echo get_template_directory_uri() . '/wpgpanel/js/jquery.js'; ?>" type="text/javascript" charset="utf-8"></script>
    <script src="<?php echo get_template_directory_uri() . '/wpgpanel/js/jquery.tabify.js'; ?>" type="text/javascript" charset="utf-8"></script>
    
    <script type="text/javascript">// <![CDATA[
    
    			$(document).ready(function () {
    				$('.wpgpanelmenu').tabify();
    			});
    
    			// ]]>
    </script> 
    
    <?php } ?>

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Java script support on my Theme options page’ is closed to new replies.