Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ajax/jquery development pattern

Status
Not open for further replies.

pilot7

Programmer
Jan 18, 2006
1
US
I am a Java developer who is working more and more with javascript. I love Jquery, but am unsure how to architect a largish ajax project.

Each widget I make will need to communicate with the server, so I have put each widget in its own directory and have it pull dynamic content from files in the same directory.

When I want a page (in another directory) to include the widget, I have taken the approach of including the appropriate .js file, instantiating the objects within it, then having the widget write its content to a div on the current page. The problem I am running into is that the objects created from the imported .js files don't seem to know which directory they came from anymore, so they cannot find the server side files they need to communicate with.

Is there a way that objects loaded from a .js file can know what their original source directory is? Is there a better way to architect this?

- Steve
 
Is there a way that objects loaded from a .js file can know what their original source directory is?

Yes there is - take a look at the source for scriptaculous.js which can be found here: It basically looks for all script elements, then finds the reference to itself, and then strips the path from the beginning.

Hope this helps,
Dan




Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top