[support] refreshing jcarousel item list without page reload

Christopher M. Jones cjones at partialflow.com
Thu Nov 18 14:19:37 UTC 2010


Sorry, missed the last few questions. JSON stands for javascript object 
notation. You use it within your javascript code. So, let's say I have a 
menu callback on the php side like so:

function page_callback(){

   $node = node_load( some node );
   print drupal_to_js($node);

}

I could call it from javascript like so:

Drupal.behaviors.mymethod = function (context) {

   $.get('http://mysite.com/page_callback', function(data){
     var node = JSON.decode(data);
     console.log( node ); // open firebug console to see the data
   }
}

This code may not be exactly right. But you get the idea.

On 11/18/2010 08:30 AM, Aldo Martinez Selleras wrote:
> I have create my modulo completly from scratch!
>
> This code, generate the li objects
>
>    for ( $x = 0; $x<  $numero; $x++) {
>      $output .= "\t<li><img src=\"$base_url/sites/default/files/backgrounds/"
> . $awards[$x]['background'] . "\" width=\"75\" height=\"75\" alt=\"".
> $awards[$x]['background'] ."\" /></li>\n\r";
>    }
>
> And I'm loading the carousel like
>
> jQuery(document).ready(function() {
>     jQuery('#profile-carousel').jcarousel({
>          vertical: true
>      });
> });
>
> $output .= "<select id=\"award-type-filter\"
> onchange=\"javascript:refresh_carousel()\">\n\r";
> $output .= "<option value=\"0\">  -- ALL --</option>\n\r";
> foreach ( $atype as $key=>$value ) {
>     $output .= "\t<option value=\"" . $key . "\">" . $value .
> "</option>\n\r";
> }
> $output .= "</select>\n\r";
>
> So, I need the function refresh_carousel() regenerate the ul>  li objects
> and recall de carousel function.
>
> What can I do with JSON data, I not found any way to format it :(
>
> {"1":background1,"2":background2,"3":background3}
>
> And how I wotk with this ?
>
>


More information about the support mailing list