Object Oriented / PHP5 - Possible BUG with Jquery

Hi Folks

I was creating a simple singleton class (but I tested with others Desing
Patterns) with php like this:

class header {
   static private $instance = false;

    private function js()
{
    <script type="text/javascript">$(document).ready(function() {
            $("#out").each(function(i){
                $(this).bind("click", function(event){
                document.form.submit();
                });
            });
    });</script>
}

    private function css() {
    }

    private function header () {
    ....
    echo $this->js().$this->css();
    ....
    <li><a id="out" href=".....">Logout</a> </li>
    </ul>
    <form method="post" name="form" action=".....">
    <input type="hidden" value="....." name="test"/>
    </form>
        ....

} // end header()

   static function instance() {
       if(!Header::$instance) {
           Header::$instance = new header();
       }
       return Header::$instance;
   }

}

My Surprise!! Jquery didnt work properly.

I tried a lot of variations and some times I changed my script adding

alert('something');

and sometimes my page received the $_POST but with the code above definitly
didnt work. (I have very similar codes in procedural style and works fine. )

Jquery didnt acept the event ("click"), but works with alert('something');

So I insert the Submit button <input type="submit" value="Submit">

and with this my page receive the $_POST.

So I am new in the amazing PHP5/OOP world and I dont know if can be a bug
from PHP/Browser/JavaScript or Jquery.

So I am reporting.

My felling tell me that I am sending all this stuffs (<script/>) to an
Object and something is going wrong there.

Hope someone can help me.

Regards

Mario
macm

Reply via email to