PDA

View Full Version : Ajax Tabs - Unable to use JS inside tabs



taylorn
11-12-2011, 11:16 AM
1) Script Title: Ajax Tabs Content Script (v 2.2)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/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.


<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)


<script type="text/javascript">

var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>

jscheuer1
11-12-2011, 04:55 PM
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.

taylorn
11-14-2011, 09:02 AM
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