> there is no cache of the value
> your problem is then on the javascript side

Maybe, but I have this problem, and doesn't look to be js the source
of the problem.

=== 8< CUT HERE >8 ===

Problem: why Genshi wanna drive me crazy?

Here there's the code. All begin in an hmtl file:

<html xmlns:py="http://genshi.edgewall.org/";
      xmlns:xi="http://www.w3.org/2001/XInclude";
      py:strip="">

<py:def function="navigator_new_collapsed">

    <div id="div_collapse" name="collapse" class="collapse_button">
      <img src="${tg.url('/images/collapse.png')}" id="img_collapse"
name="collapse" class="collapse_image" onclick="collapse1( '' )" />
    </div>

</py:def>

<py:def function="navigator_new_expanded">

    <div id="div_server_datetime" name="server_datetime"
class="server_datetime">
      ${dataora}
    </div>

[…]

    <div id="div_system" name="system" class="bluette link nine center border1">
      System
    </div>

    <div id="div_collapse" name="collapse" class="collapse_button">
      <img src="${tg.url('/images/collapse.png')}" id="img_collapse"
name="collapse" class="collapse_image" onclick="collapse1( '0' ) " />
    </div>

</py:def>

</html>

The invoked Javascript is that:


function collapse1( stato )
{
  var URL = "collapsed_navigator";

  if( stato == '0' )
  {
    $.ajax( {  url:     URL,
               type:    "POST",
               data:    "collapsed2="+stato,
               complete: function( html )
                        {
                          alert( "0" + html.responseText );
                          $( '#div_navigator' ).html( html.responseText ) ;
                          $( '#div_navigator' ).css( "width", 10 );
                          $( '#div_context' ).css( "width", 970 );
                          $( '#div_collapse' ).css( "left", 5 );
                          $( '#div_collapse' ).css( "top", 230 );
                        }
            }
          );
  }
  else
  {
    $.ajax( {  url:     URL,
               type:    "POST",
               data:    "collapsed2="+stato,
               success: function( html )
                        {
                          alert( "1" + html.responseText );
                          $( '#div_navigator' ).html( html.responseText ) ;
                          $( '#div_navigator' ).css( "width", 65 );
                          $( '#div_context' ).css( "width", 915 );
                          $( '#div_collapse' ).css( "left", 60 );
                          $( '#div_collapse' ).css( "top", 230 );
                        }
            }
          );
  }
}


URL is the controller (root.py), and here there the interested metod:


# -*- coding: utf-8 -*-
"""Main Controller"""

from tg import expose, flash, require, url, request, redirect
from pylons.i18n import ugettext as _, lazy_ugettext as l_

from newweb.lib.base import BaseController
from newweb.model import DBSession, metadata
from newweb.controllers.error import ErrorController

from tw.api import WidgetsList
from tw.forms import TableForm, CalendarDatePicker, SingleSelectField,
TextField, TextArea

from tg import tmpl_context
from newweb.widgets.quicksearch_form import create_qsearch_form
import datetime

[…]

    @expose( 'newweb.templates.navigator' )
    def collapsed_navigator( self, collapsed2 ):
        """Return the collapsed menu"""
        now     = datetime.datetime.now()
        dataora = now.strftime( "%d-%m-%Y %H:%M" )
        print "###%s###" % ( collapsed2 )
        return dict( collapsed2=collapsed2, dataora=dataora, user='Admin' )

Last but don't least the used template:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:py="http://genshi.edgewall.org/";
      xmlns:xi="http://www.w3.org/2001/XInclude";
      py:strip="">
    <xi:include href="navigator_new.html" />

    ${collapsed2}
    <py:if test="collapsed2 == ''">FALSE</py:if>
    <py:if test="collapsed2 != ''">TRUE</py:if>
    ${navigator_new_collapsed()}

</html>

Good, the strange behaviour is that the first step go really good, the
alert show “0” and the HTML code returned is correct ( 0 TRUE ). In
the Firebug Console, the HTML Tab return correctly (0 TRUE).
When I try to hit again the button, that now will invoke the Ajax call
with the stato variable as null string, the Alert show “1Undefined”
(correct the 1 but nt the Undefined as html.responseText), on the
screen doesn't change nothing (0 True) but the Firebug Console Html
Tab show the right (FALSE), as attended.

=== 8< CUT HERE >8 ===

Greetings
JOKER Ltd.
-- 
Mr. Gandhi, cosa ne pensa della civiltà occidentale? - Sarebbe
un'ottima idea! ( intervista al Mahatma Gandhi )

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to