Hi,
Your way of doing this is not the web.2 way ;) You request the whole content on beforehand, even when you don't need it. Also you risk that single quotes inside news and article break the code.
If you do it like that then the only thing you could do is to put the include stuff in the call:
<a include "news.php"?>');">Insert News Div</a>
<a include "article.php"?>');">Insert News Div</a>
ect...
JS File:
function xxxNew(content) {
element = new Insertion.Top('left_column', content);
startDragging();
updateRanking();
}
The web2 way would be to start some ajax request to news.php or article.php and putting in the ajax.responseText.
Something like this:
<a News Div</a>
<a News Div</a>
ect...
JS File:
function xxxNew(url) {myAjax = new Ajax.Request(url,
{
method : 'get',
onComplete : function (ajax){
element = new Insertion.Top('left_column', ajax.responseText);
startDragging();
updateRanking();
}
});
}
The nice thing is that the file included can be determined on runtime.
Try experimenting with that ;)
Have Fun
Fabian
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On Behalf Of Tristan Kelley
Sent: Dienstag, 25. Juli 2006 20:39
To: rails-spinoffs@lists.rubyonrails.org
Subject: [Rails-spinoffs] Passing Variables to Insert.Top
Hi all,
I have an index page with a link to a JS file with many Insert.Top functions in it. I'd like to have just one function if at all possible. Here's an example of what I currently have:
On the index.php page:
<a News Div</a>
<a News Div</a>
ect...
JS File:
function newsNew() {
element = new Insertion.Top('left_column', '<?php include "news.php"?>');
startDragging();
updateRanking();
}
function articleNew() {
element = new Insertion.Top('left_column', '<?php include "article.php"?>');
startDragging();
updateRanking();
}
Is there a way I can have just one function and pass a variable for what PHP file I'd like to have included? Thanks!
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs