Support » Fixing WordPress » Using script for tooltips

Viewing 12 replies - 1 through 12 (of 12 total)
  • Are you enqueueing the script(s) correctly?

    Thread Starter Theopt

    (@theopt)

    they work in a blank page 😐 outside word-press

    example: http://www.dawnsource.com/work/

    Are you enqueueing the script(s) correctly?

    Thread Starter Theopt

    (@theopt)

    do u mean wp_enqueue_script? Im not using it at all. Do I have to? 😡

    What i’ve read was this: http://codex.wordpress.org/Using_Javascript

    Yes – you should enqueue all .js scripts.

    Thread Starter Theopt

    (@theopt)

    How do I do that? I dont get the wordpress tutorial for that :S

    Thread Starter Theopt

    (@theopt)

    Yes but I’ve tried to post that php code and it doesnt load me (on the post, or do I have to post it on header.php?)

    You have to enqueue the .js file via a function in your theme’s functions.php file and then hook it to an action using something like add_action('template_redirect', 'function_name');

    Thread Starter Theopt

    (@theopt)

    but I cant past php code in pages, it removes it I think so how to do the add_action part?

    edit: tried it on page.php and header.php but nothing

    Thread Starter Theopt

    (@theopt)

    add_action('init', 'register_my_script');
    add_action('wp_footer', 'print_my_script');
    
    function register_my_script() {
    	wp_register_script('ntip', plugins_url('http://dawnsource.com/work/js/ntip.js', __FILE__), array('jquery'), '1.0', true);
    	wp_register_script('my-script', plugins_url('http://dawnsource.com/work/js/jquery-1.3.2.min.js', __FILE__), array('jquery'), '1.0', true);
    	wp_register_script('mine1', plugins_url('http://dawnsource.com/work/myscript.js', __FILE__), array('jquery'), '1.0', true);
    	wp_register_script('mine2', plugins_url('http://dawnsource.com/work/myscript.js', __FILE__), array('jquery'), '1.0', true);
    }
    
    function print_my_script() {
    	global $add_my_script;
    
    	if ( ! $add_my_script )
    		return;
    
    	wp_print_scripts('my-script');
    	wp_print_scripts('ntip');
    	wp_print_scripts('mine1');
    	wp_print_scripts('mine2');
    }

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    shouldnt this do it?

    Thread Starter Theopt

    (@theopt)

    var de = document.documentElement;
    			var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
    			var hasArea = w - jQuery.fn.getAbsoluteLeftObject(this);
    			var clickElementy = jQuery.fn.getAbsoluteTopObject(this) - 3; //set y position
    			var title=" ";
    			jQuery("body").append("<div id='NT'><div id='NT_copy'><div >"+jQuery(this).children("."+settings.tooltipcontentclass).html()+"</div></div></div>");//right side
    			var arrowOffset =  this.offsetWidth + 11;
    			var clickElementx = jQuery.fn.getAbsoluteLeftObject(this) + arrowOffset;
    			jQuery('#NT').css({left: clickElementx+"px", top: clickElementy+"px"});
    			jQuery('#NT').css({width: settings.width+"px"});
    			jQuery('#NT').css({position: settings.postion});
    			jQuery('#NT').css("z-index",settings.zindex);
    			jQuery('#NT').show();

    this is whats not working on my script

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Using script for tooltips’ is closed to new replies.