Problem with Request.HTML and inject(); Ignores CSS

55 views
Skip to first unread message

hamburger

unread,
Jul 26, 2010, 6:48:52 AM7/26/10
to MooTools Users
Hello,
I have a Problem with my code.
I would like to load more content by scrolling down. This works fine.
Scrolling down to the end of my page loads via ajax (request.html)
more content.
But the new content ignores my css-statements and destroys my layout.
If I copy the loaded text direct to my code it will be shown correct.
have a look here: http://www.opteynde.com/test_BilderListe3.html

here my js:

(function($) {
//domready event
window.addEvent('domready',function() {
//settings on top
var initialPosts = 0;
var start = 0; //<?php echo $_SESSION['posts_start']; ?>;
var desiredPosts = 0; //<?php echo $number_of_posts; ?>;

var url = 'http://www.opteynde.com/LazyPagination.php';
var paged = 2;
var requests = 0;
var maxRequests = 5;
var abstandvonunten = 200; /* tolerance */;

var spy;
var spyAct = function() {
var min = document.getScrollSize().y - document.getSize().y -
abstandvonunten;
spy = new ScrollSpy({
min: min,
onEnter: function() {
//alert("jetzt");
if(requests != maxRequests)
datenHolen.send({
data: {paged: paged, ajax: 1, page: null}
});
}
});
};

//wait for first load...
window.oneEvent('load',function() {
spyAct();
});


//ajax!

var datenHolen = new Request.HTML ({
url: url,
method: 'get',
//update: $('hier'),
onRequest: function(){
$('gototop').set('html','Load ...('+paged
+')');
//$('gototop').highlight('#fff','#ccc');
},
onComplete: function(response,html) {
//html[0].inject($('work'),'bottom'); //loads only first
div
html.inject($('work'),'bottom');
//console.log(html);
},
onSuccess: function(){
start += desiredPosts;
requests++;
paged++;
spyAct();
(function() {$('gototop').set('html','Top of
Page');}).delay(1000);

},
onFailure: function(){
alert("failure ajax");
}
});


});
})(document.id);

thanks for an help in advance (I do not have any idea what could be
wrong here)

brook

unread,
Jul 26, 2010, 9:01:18 AM7/26/10
to MooTools Users
are you sure its not an issue with your css rather than your
javascript. in particular, do you have multiple div's with the same
id? I´ve notice some browsers allow you to get away with this - but
if i load it with ajax it will fail.

hamburger

unread,
Jul 26, 2010, 9:19:50 AM7/26/10
to MooTools Users
thx brook
i deleted all ID's in the ajax call. same result.

keif

unread,
Jul 26, 2010, 9:29:13 AM7/26/10
to MooTools Users
Your site throws two JavaScript errors - one is you're calling a 404
and the other, 'html is undefined'

-kb
Message has been deleted
Message has been deleted

hamburger

unread,
Jul 26, 2010, 9:38:47 AM7/26/10
to MooTools Users
to keif,
sorry i deleted my php-file. its repaired ..

hamburger

unread,
Jul 26, 2010, 9:53:38 AM7/26/10
to MooTools Users
html[0].inject($('work'),'bottom'); works and shows the correct
result.
but it loads only the first div and i want all ..

any idea??

hamburger

unread,
Jul 26, 2010, 10:28:24 AM7/26/10
to MooTools Users
If i have a look in firebug i see that the request.html is closing my
open <divs>
php sent this:
<DIV class="featured p1 post">
<DIV class="post-content"><P>test bild 1 This ...

firebug shows this:
<DIV class="featured p1 post"></DIV>
<DIV class="post-content"></DIV>

is this a bug in moo?

Paul Saukas

unread,
Jul 26, 2010, 10:39:53 AM7/26/10
to mootool...@googlegroups.com
you should be closing your divs to start with. then inserting the requested html in to the div.

$('.post').set('html',requestHtml)
Reply all
Reply to author
Forward
0 new messages