I think this may be resolved by using the *live* method but my
inexperience with jQuery is getting me nowhere..
below is a condensed version of Sam Shull's extension adding iScroll
to a jqt class ,
any suggestions would be appreciated.
(function($)
{
$.fn.scrollVertically = function (options)
{
return this.each(function ()
{
new iScroll( this, options );
});
};
if ($.jQTouch)
{
$.jQTouch.addExtension(function (jQTouch){
function binder (info)
{
vertical = info.page.find('.vertical-scroll > div');
vertical.scrollVertically({acceleration: Number(vertical.attr
("scrollspeed") || 0.009)});
}
$(document.body)
.bind('pageInserted', binder);
$(function()
{
$('body > *')
.each(function()
{
binder({page: $(this)});
});
});
});
Using $('body > *).each most of the time is a horrible thing to do. It
can be a huge, huge resource- and memory hog and should be avoided to
all time.
And why exactly do you want to make a jQTouch plugin out of something
that already is a jQuery plugin? This seems a tat pointless in my
mind, it should either be a jQuery plugin, or a jQTouch plugin. Most
likely a jQTouch plugin in this case, because of the pageInserted
trigger (only exists in jQTouch?)
Here's a short example of how you can make things a tat simpler:
function binder ( scope ) {
var $vertical = $('.vertical-scroll > div', scope.page); // using a
second parameter to jQuery is scope, that it only searches within that
node (similar to $(obj).find('.whatever');
$vertical.scrollVertically({accelleration: Number($vertical.attr
('scrollspeed') || 0.009}); // assumes scrollVertically method is a
jQuery plugin, will most likely need to be changed if jQTouch.
}
$(function(){
binder ( {page:$document} ); // initialize it for the document
$(document).bind('pageInserted', binder); // call on insert,
pageInserted privides with node.page (=object inserted) I take it?
});
This will probably not work straight out of the box, but it sort of
demonstrates my point.
Good luck, sorry if I confused you more,
Jonas
Anyway, you can get the new example here (http://
jqextensions.googlecode.com/files/example.zip) and I added an ajax
loaded example, and an example with a sticky footer, just for fun. :)