In order to integrate the scrollto javascript in a wordpress theme,
I need to dynamically generate the following script:
Code:
$(function(){
// Prepare
var links = [
{
id: 'scrollto1',
text: 'some text'
},
{
id: 'scrollto2',
text: 'some text',
},
{
id: 'scrollto3',
text: 'sometext',
}
];
// Fetch
var $links = $('#scrollto-links');
// Append Links
$.each(links,function(i,link){
$('<a>'+link.text+'</a>').click(function(){
$('#'+link.id).ScrollTo(link.options);
}).appendTo($links);
});
});
And this for a X numbers that i will get through counting some posts with a php function I guess.
I tried the following code without success:
Code:
$(function(){
// Prepare
for (var i=0;i<6;i++)
{
links = [
{
id: 'scrollto',
text: 'Scroll to #scrollto'+[i]
}
];
}
// Fetch
var $links = $('#scrollto-links');
// Append Links
$.each(links,function(i,link){
$('<a>'+link.text+'</a>').click(function(){
$('#'+link.id).ScrollTo(link.options);
}).appendTo($links);
});
});
Any help is welcome ;-)
Thanks,
f