[FX.php List] JavaScript, AJAX, jQuery assistance?

Michael Ward headhoncho at customikesolutions.com
Fri Sep 28 18:10:24 MDT 2007


Hi Joel,

On 28/09/2007, at 2:46 PM, Joel Shapiro wrote:

> Hi Michael
>
> Thanks for the reply.  Unfortunately, neither of these options work  
> satisfactorily:
> Including JT_init(); as part of the LAJAX callback causes duplicate  
> displays of the original tooltip (at least in Safari), and adding  
> JavaScript to the called page (ajaxpage.html) doesn't actually fire  
> off the JavaScript.
>
> Steve Winter thinks that it's the way that LAJAX writes content to  
> the div that's the problem.  He recommends prototype, through which  
> he says "you can explicitly allow or deny the running of scripts  
> within loaded files during the call to that file".  I'll be giving  
> that a try, as well as looking at how jQuery might do this.  (Do  
> you know this already?  Is it easy to figure out?)

Hmm... mixing different libraries is always a quandary.

I have now had a look at your code and have made it all "jQuerified"  
so it now works.

I've actually done it two ways...

1)

I removed references to Lajax and called JT_init on document load:

$(function(){
		JT_init();
     });

this takes care of the first tootip on the original page.

I then use the "load" jQuery function to load "ajaxpage.html" into  
the "getDiv" div calling JT_init  as a callback:

<a href="#" onClick="$('#getDIV').load('ajaxpage.html',function() 
{JT_init();});"> link here</a>

This now works fine in FireFox, although there appears to be an  
artifact (the tooltip header) in safari.

2)

I called both JT_init and "preloaded" the "load" event (attached to a  
"p" tag) on document load:

	$(function(){
		JT_init();
		$('p.getDiv').click(function() {
		$('#getDIV').load('ajaxpage.html',function(){JT_init();})
     });
	return false;
}
);

Which basically says... when you click the "p" tag with a getDiv  
class, do the jTip stuff.

So when you click on the paragraph text, the div is loaded.  I  
haven't done anything to alert the user that this paragraph is  
"clickable"!

The benefit of this way is that you can send different pages into the  
load callback, (based on some criteria in the "p" tag)

I briefly covered a way to do this in my DevCon presentation (INT610)  
and the code can be found in folder "20".  You'll need to digest  
"final.php" (the page that is called),  "pubs.php" ( a loaded div)  
and "articles.php" (the different "tooltips" that are called) to make  
sense of it.

One last thing... If it were me, I'd be working in only one  
Javascript library, unless you have been given code that works  
solidly and you need to extend it.

I don't know if this list supports attachments so have sent this  
email back channel as well.  If anyone wasn't at DevCon and wants a  
copy of the presentation files, please let me know.

Regards

Michael Ward
--
Head Honcho
CustoMike Solutions
Member, FileMaker Business Alliance
Member, FileMaker Technical Network
FileMaker 7 Certified Developer
FileMaker 8 Certified Developer
10 Wandoo Crt
Wheelers Hill, 3150
ph 0414 562 501
headhoncho at customikesolutions.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Archive.zip
Type: application/zip
Size: 2538 bytes
Desc: not available
Url : http://www.iviking.org/pipermail/fx.php_list/attachments/20070929/ca31ce38/Archive.zip
-------------- next part --------------



More information about the FX.php_List mailing list