WordPress.org

Ready to get started?Download WordPress

Forums

Ajaxize
[resolved] call function onClick (7 posts)

  1. 2046
    Member
    Posted 2 years ago #

    Hello

    can you help me to find a way how to call function through Ajaxize on object Click.
    As I understood, default the ajax call is made on the page load. But how can we call it on mouse click?
    I have tried to "hack" the refresh example from the FAQ but with no luck.

    thanks in advance 2046

    http://wordpress.org/extend/plugins/ajaxize/

  2. 2046
    Member
    Posted 2 years ago #

    simple hack is
    go to ajaxize_this.js and hack it this way

    [Code moderated as per the Forum Rules. Please use the pastebin]

    that does the trick. What is the trick?
    The trick is that the ajax call is done only when somebody clicks on the html object with given CSS id :)

    sweet ;)

  3. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Hi 2046,

    Glad to see some enhancements, but your code was removed by the moderators. Can you please post it on pastebin as advised so other people can also benefit from it??

  4. 2046
    Member
    Posted 2 years ago #

    hope the code will reach the other end of line.
    here is the link to the changed code http://pastebin.com/FMPdZ8yR

    btw, be aware that the internal plugin test function stop working(because the code does not run onLoad)
    And that you have no flexibility for different div elements then the one you define in the changed code, plus if you update the plugin, all changes are lost indeed.

  5. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for sharing the code 2046.

    Would be nice if you can give positive feedback about ajaxize if you like it!

  6. radiofranky
    Member
    Posted 2 years ago #

    hi,

    I'm trying to get my sidebar.php ajaxed so that everytime I click on link on sidebar.php the class in page.php will gets refreshed and not the sidebar.php.

    I tried the hack but is not working. Could you please show me how to get sidebar.php ajaxed? Thanks

    this is my code for sidebar.php

    <h2>Related Videos</h2>
    					<div id="scroll-pane">	<div id="scroll-content">
    <?php
    $IDOutsideLoop = $post->ID;
    while( have_posts() ) {
    	the_post();
    	foreach( ( get_the_category() ) as $category )
    		$my_query = new WP_Query('category_name=' . $category->category_nicename . '&orderby=date&order=desc&showposts=100');
    	if( $my_query ) {
    		while ( $my_query->have_posts() ) {
    			$my_query->the_post(); ?>
    
    <div class="scroll-content-item">
    							<div class="singleright">
    				<div class="single_img_block_img"><div class="side_img_block"><a href="<?php the_permalink() ?>"  rel="bookmark" title="<?php the_title_attribute(); ?>"><?php $vthumb = get_post_meta($post->ID, 'video_thumb', true);  echo '<img src="http://i.ytimg.com/vi/'.$vthumb.'/default.jpg" width=96px height=72px/>';?></div></a></div>
    				<div class="singlerighti">
    					<div class="singlerightinfo">
    						<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $tit = the_title('','',FALSE); echo substr($tit, 0, 150); if (strlen($tit) > 150) echo " ..."; ?></a>
    					</div>
    					<div class="postviews">
    						<?php if(!function_exists('easy_relative_date')){the_time('F jS, Y'); } else { echo easy_relative_date(get_the_time('U')); } ?>
    					</div>
    					<div class="postviews">
    						<?php if(function_exists('the_views')) { the_views(); } ?>
    					</div>
    				</div>
    			</div>
    			</div>
    <?php
    		}
    	}

    this is my single.php

    <div class="singlebody">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    			<div class="singlepost">
    
    				<h2><?php the_title(); ?></h2>
    
    					<?php the_content(); ?>
    <div class="pagenumbers"><?php wp_link_pages(array('before' => '<div class="font_normal">一共有: </div>','after' => '', 'next_or_number' => 'number'));  ?><?php wp_link_pages(array('before' => '', 'next_or_number'=>'next', 'previouspagelink' => ' &laquo; Go Back  ',  'nextpagelink'=>'  Watch 下一個片段 &raquo; ')); ?>
    </div>
    		<div class="postinformation">
    
    						<div class="single_postviews">
    						<?php if(function_exists('the_views')) { the_views(); } ?>
    					</div>
    					<p><font style="font-weight:bold;">Post Date:&nbsp;</font> <?php if(!function_exists('easy_relative_date')){the_time('F jS, Y'); } else { echo easy_relative_date(get_the_time('U')); } ?><br>
    
    						<font style="font-weight:bold;">Category:&nbsp;</font> <?php the_category(', ') ?><br>
    						<?php the_tags( '<font style="font-weight:bold;">Tags:</font> ', ', ', ''); ?></p>
    						</div>
    
    					<?php include (TEMPLATEPATH . '/sidebar_single.php'); ?>
    
    				</div>
  7. 2046
    Member
    Posted 2 years ago #

    Ajaxize Ajaxizes functions.
    If I understand right you click on the link only(in sidebar) and do not call "any" function.

    If you want to call the post content via ajax(Ajaxized) then the link has to call a function which will be hooked to Ajaxized..
    so you have to make a function that holds the loop and from sidebar call that function.

    little bit step by step coding might be better solution..depends
    http://www.emanueleferonato.com/2010/04/01/loading-wordpress-posts-with-ajax-and-jquery/

    I'm sure you thought about it already, but I found out Ajax post loading non-user friendly... when they hit back they do not understand why they do not see what they saw :).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags