Results 1 to 3 of 3

Thread: Ajax Tabs - Unable to use JS inside tabs

  1. #1
    Join Date
    Nov 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax Tabs - Unable to use JS inside tabs

    1) Script Title: Ajax Tabs Content Script (v 2.2)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tent/index.htm

    3) Describe problem:
    I have found that I cannot use any javascript inside the DIV that the Ajax Tabs script uses.

    For example:

    If I were to place a JS script that pulls some info from our WHMCS system into the DIV (below) it wouldn't appear, however it appears in the HTML source code.

    Code:
    <div id="countrydivcontainer" style="border:1px solid gray; width:450px; margin-bottom: 1em; padding: 10px">
    <script type="javascrtipt" src="xx/xx.php"></script>
    </div>
    Also, if I put JS inside one of the pages/containers/tabs, it also doesn't work, and has the same outcome.

    I removed the JS (below) and it works correctly (inside the div anyway, because obviously the tabs don't work)

    Code:
    <script type="text/javascript">
    
    var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    
    </script>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The general answer is to use the onajaxpageload function to run functions in a script or scripts against imported content after it's imported. Those script(s) should be on the 'top' page, and not within the container division where they will be overwritten. Imported scripts rarely run, and if they do can do so in unexpected ways and/or differently in different browsers.

    The specifics depend upon what you want to happen. And depending upon your objectives, this script might not be flexible enough.

    If you want more help, please supply a link to a page that shows your script(s) (not Ajax Tabs) working, and one to a page without your script(s) that shows how you want to use Ajax Tabs. Or if you're almost there at combining them, a page showing your best effort at that.
    Last edited by jscheuer1; 11-12-2011 at 05:08 PM. Reason: add clarity and an option
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello

    The script I am using HAS to be used in the DIV, as its a widget and it pulls info from a PHP file. Basically its /scripts/getprice.php and its called as a JS file, and outputs the price of a product from our SQL DB/ So getprice.php?pid=xx&billingcycle=monthly. etc etc. Also, I might mention - this issue happens inside the tabs as well, not just in the DIV tags - i tested with the DIV tags AFTER I realised it wouldn't work inside the containers.

    However, there is no output from it when inside an AJAX tabs container, but it works everywhere else. I was going to call it as PHP, and change the 'document.write ($value)' to just $value, but I can't figure out how to do it...

    Can you think of a way to stop the JS' from conflicting?

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •