Hi all,

I have to control my application formcontrols using css. My application run
as master or slave. If the application is in slave mode. I have to disable
all the form fields(uneditable) in all the pages. otherwise it will be
editable(if my application is in master mode).

I have common.kid file. The following code snippet is as follows

================================================
<?python
import myapp

def loadcss():
    if myapp.isMaster():
        return XML('<link href="/static/master.css" type="text/css"
rel="stylesheet" />
                         <script type="text/javascript"
src="/static/master.js"></script>')
    else:
        return XML('<link href="/static/slave.css" type="text/css"
rel="stylesheet" />
                          <script type="text/javascript"
src="/static/slave.js"></script>')
?>
<html xmlns:py="http://purl.org/kid/ns#";>

<head py:match="item.tag == 'head'">
      <link py:replace="loadcss()" />
    <div py:replace="[item.text] + item[:]">Page specific headers</div>
</head>

<body py:match="item.tag == 'body'" py:attrs="item.attrib" onload="init()">
          <div>
                ... Common content to all pages ...
           </div>
         <div py:replace="[item.text] + item[:]">
            Page content goes here.
        </div>
</body>
</html>
======================================================

I have another page named as page.kid. It contains some text to
display. I wrote <body onload="init()"> in page.kid.

while i run my application, the slave.js init() method not loading on body.
I have init method on master.js and slave.js. How can i override this.

I have tried like this
=======================================================
<body py:if="myapp.isMaster():" py:match="item.tag == 'body'" py:attrs="
item.attrib">
           <div>
                ... Common content to all pages ...
           </div>
         <div py:replace="[item.text] + item[:]">
            Page content goes here.
        </div>
</body>

<body py:if="not myapp.isMaster():" py:match="item.tag == 'body'"
onload="init()">
           <div>
                ... Common content to all pages ...
           </div>
         <div py:replace="[item.text] + item[:]">
            Page content goes here.
        </div>
</body>
=========================================================
Its working fine. But my code looks ugly. In body I have more than 25 lines.
I replicate the same for single condition.

I want to change the body line only

if myapp.isMaster(): <body py:match="item.tag == 'body'" py:attrs="
item.attrib">
else: <body py:match="item.tag == 'body'" onload="init()">

How can i do the single line change in kid.

Please anyone help me.

Thanks in advance.

- Basha.S
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
kid-template-discuss mailing list
kid-template-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kid-template-discuss

Reply via email to