I have a script that will make the index page only display the 5 most recent blog posts (handeled by it's cms-repeat class). It works fine, until I use PageLime (online light CMS) to add new blog posts (It just duplicates an article that you then edit). For some reason, somemthing PageLime does kills the script and I cant figure out why. I grabbed my html off the server to have a look, but still don't see anything that is preventing the script from running.
Here's the main body section, footer, script code:
<section class="wrapper blog-page">
<article id="editableBlogPost-1" class="cms-editable cms-repeat clearfix">
<h2>Paper Towl Rolls</h2>
<p>text...</p>
</article><article id="e24450" class="cms-editable cms-repeat clearfix cms-previous-repeat-item-id-editableBlogPost-1" style="display: block;">
<h2>No Storytime today!</h2>
<p>text...</p>
</article><article id="e15438" class="cms-editable cms-repeat clearfix cms-previous-repeat-item-id-editableBlogPost-1" style="display: block;">
<h2>New Resources for Families</h2>
<p>text...</p>
<p><img id="e42608" src="/cms-assets/images/512037.optimized-may12-2-1.jpg" alt="Image of new books at the Logan Family Center, Anxiety, depression, self-esteem and shyness" width="300" height="224" /> <img id="eca5c2" src="/cms-assets/images/107497.optimized-may12-1.jpg" alt="Photo of new family resource books, Anxiety, depression, self-esteem and shyness" width="300" height="224" /></p>
<p> </p>
</article><article id="e3c688" class="cms-editable cms-repeat clearfix cms-previous-repeat-item-id-editableBlogPost-1" style="display: block;">
<h2>Around the World Presenters</h2>
<p>text...</p>
</article><article id="e70d96" class="cms-editable cms-repeat clearfix cms-previous-repeat-item-id-editableBlogPost-1" style="display: block;">
<h2>Do You Have What it Takes?</h2>
<p>text...</p>
</article><article id="e2016e" class="cms-editable cms-repeat clearfix cms-previous-repeat-item-id-e70d96" style="display: block;">
<h2>Ready! Set! School! - <span>Let's Read!</span></h2>
<p><span><img id="e91bf1" src="/cms-assets/images/169742.optimized-april15.jpg" alt="Image of Ready! Set! School! Books used in the Lets Read lesson" width="300" height="225" />text...</span></p>
<p> </p>
</article><article id="e30bb5" class="cms-editable cms-repeat clearfix cms-previous-repeat-item-id-e2016e" style="display: block;">
<h2>Welcome back</h2>
<p><img id="e5597d" src="/cms-assets/images/287627.optimized-april8.jpg" alt="Image of Ready! Set! School! student with book, everybody counts lesson" width="300" height="225" /><span>text...</span></p>
</article>
<input type="button" id="more" value="More">
</section>
<footer class="page-footer">...</footer>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script>
//display next 5 blog posts when "#more" is clicked
size_article = $('.cms-repeat').size();
x=5;
$('.cms-repeat:lt('+x+')').slideDown('slow').show();
$('#more').click(function () {
x= (x+5 <= size_article) ? x+5 : size_article;
$('.cms-repeat:lt('+x+')').slideDown('slow').show();
alert('its working?');
});
//hides "Please enable javascript" message for those with javascript
$("#no-script").hide();
</script>
Problem was that PageLime added the style="display: block" as inline CSS to most of my articles, which of course had higher specificity than my script. I couldn't find anything about turning off inline styles with Page Lime, so I'm just adding another bit of jQuery before the other in order to remove the style attr first.
$('article').removeAttr("style");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.