Hi I’m using django and the jquery expander plugin http://plugins.learningjquery.com/expander/. When I use the default example everything works properly. But when I try to use it with database data it doesn’t work. Is it possible that the script is executed before the data is rendered? Any suggestion on getting this right?
edit
ok I found the problem. The linebreakfilter generates more than one p tag and abunch of br tags.
js:
$(document).ready(function() {
$('div.expandable p').expander({
slicePoint: 50, // default is 100
expandPrefix: ' ', // default is '... '
expandText: 'show more', // default is 'read more'
userCollapseText: 'show less' // default is 'read less'
});
});
html working:
<div class="expandable">
<p>ljddf adfsdf esaf nmnj asdf adsfsdafsdf</p>
</div>
html working:
<div class="expandable">
<p>{{ object.description }}</p>
</div>
I’ve pointed out the problem. The linebreaksfilter adds some p and br tags to format the output. Instead of:
It creates something like this:
So the jquery expander plugin won’t work correct with the output of djangos linebreaks filter.