Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Other
Author Message
hicuxunicorniobestbuildpc
Life Cycles Becoming CPU Cycles


Joined: Aug 13, 2009
Posts: 967
Location: Netherland

PostPosted: Sun Nov 02, 2014 8:31 am Reply with quote

I found out there lots of javascript code in Your Account module I was trying to converted.

users.php

Code:
    echo '<script type="text/javascript">

          var usercfg=new ddajaxtabs("usertabs", "usertabcontainer")
          usercfg.setpersist('.$persist.')
          usercfg.setselectedClassTarget("link")
          usercfg.init()
          </script>';


Should I convert it like this?

Code:
   $userinlineJS = '

   <script type="text/javascript">
   /* <![CDATA[ */
   $(document).ready(function() {
        var usercfg=new ddajaxtabs(\"usertabs\", \"usertabcontainer\")
        usercfg.setpersist(\'.$persist.\')
        usercfg.setselectedClassTarget(\"link\")
        usercfg.init()
          });
   /* ]]> */
   </script>';
   addJSToBody($userinlineJS, 'inline');


or

Code:
$userinline_js = '<script type="text/javascript">' . PHP_EOL

            . '/* <![CDATA[ */
            . 'var usercfg=new ddajaxtabs(\'usertabs\', \'usertabcontainer\');' . PHP_EOL
            . 'usercfg.setpersist(\'.$persist.\');' . PHP_EOL
            . 'usercfg.setselectedClassTarget(\'link\')' . PHP_EOL
            . 'usercfg.init();' . PHP_EOL
            . /* ]]> */;' . PHP_EOL
            . '</script>' . PHP_EOL;
addJSToBody($userinline_js, 'inline');



Is this the right way? Let me know if I need to add something else.
 
View user's profile Send private message Visit poster's website
neralex
The Mouse Is Extension Of Arm


Joined: Aug 22, 2007
Posts: 1286
Location: Germany

PostPosted: Mon Nov 03, 2014 5:37 am Reply with quote

There is no need to convert it because all is fine.

CDATA is also not needed in this case. Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
hicuxunicorniobestbuildpc
PostPosted: Mon Nov 03, 2014 8:26 am Reply with quote

Very Happy Wow! I guess u have been search a lot there! Thanks

So it should be

Code:
$userinline_js = '<script type="text/javascript">' . PHP_EOL

            . 'var usercfg=new ddajaxtabs(\'usertabs\', \'usertabcontainer\');' . PHP_EOL
            . 'usercfg.setpersist(\'.$persist.\');' . PHP_EOL
            . 'usercfg.setselectedClassTarget(\'link\')' . PHP_EOL
            . 'usercfg.init();' . PHP_EOL
            . '</script>' . PHP_EOL;
addJSToBody($userinline_js, 'inline');


After doing this I can load includes/tabcontent/tabcontent.js at the end of my page without having any issue. Now I understand why loading all my js files were causing some issues. The only case I still need to figure it out is jquery.js which can not be at the end of the page. Very Happy
 
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6792
Location: Ha Noi, Viet Nam

PostPosted: Thu Nov 06, 2014 4:17 am Reply with quote

It's all about the loading order. If I remember correctly tabcontent.js is a plug-in so jquery.js has to be loaded first, otherwise the plug-in will fail.
If I remember correctly (don't have my files in front of me) we load jquery.js by calling jquery.php because there is some logic in there specifically for Your Account.
 
View user's profile Send private message Send e-mail
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Other

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©