javascript - How to use jQuery within PHP -


i'm using php tree browser got http://www.lateralcode.com/directory-trees-with-php-and-jquery/

<?php  $path = ".";   function createdir($path = '/')  {    if ($handle = opendir($path))    {    echo "<ul>";     while (false !== ($file = readdir($handle)))     {     if (is_dir($path.$file) && $file != '.' && $file !='..')      printsubdir($file, $path, $queue);     else if ($file != '.' && $file !='..')      $queue[] = $file;    }     printqueue($queue, $path);    echo "</ul>";   }  }   function printqueue($queue, $path)  {   foreach ($queue $file)    {    printfile($file, $path);   }   }   function printfile($file, $path)  {    echo "<li><a style=\"cursor:pointer\" ".        "onclick=\"parent.right.document.getelementbyid('file_path').value='".        "$file_path'\">$file_path</a></li>";  }   function printsubdir($dir, $path)  {   echo "<li><span class=\"toggle\">$dir</span>";   createdir($path.$dir."/");   ?>   **<script language="javascript">    $(document).click(function(e) {     if (e.button == 0) {     // left button     alert('clicked');     }   });   </script>**   <?php    echo "</li>"; 

however, want detect right-click pressed inbetween, can trigger event. however, can't seem jquery code work within php. reason being, don't alert popup when execute code ... ideally, want have included within php code, since need use php variable $file_path

php can process code , send output browser. jquery runs strictly in browser , either executed when dom loads (ie, when php sends , browser receives/processes it) or when document has finished loading (usually preferable). latter use this:

$(document).ready(function() {    $(document).click(function(e) {     if (e.button == 0) {     // left button     alert('clicked');     }   }); }); 

i'm making assumption code correct because isn't extremely clear you're trying do. might shore of problems.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -