UL Disappearing

Trying to populate a blank ul list in a Rich Text Widget but cant. Every time I try, it removed the ul from my code. Can anyone help me with this?

Hey Matt,

If you are trying to populate a blank UL > LI with no content in li’s and you are looking to be able to save it, try this in the Edit HTML area of the Rich Text Widget:


 
-  
 
  

That worked for keeping my UL there but my JQuery won’t run against my UL now. Hmmmmm. I have it working on a .html page without percussion but when I include it in percussion it won’t work anymore.

Interesting. How about giving your UL an id or a class and utilizing the id in the Jquery?


 
-  
 
  

Matt,

What is the jQuery you are calling? My guess is the selector doesn’t match the output of the HTML from CM1.

David,
This is what my script looks like.

<script type="text/javascript"> <br />
 $(document).ready(function(){
<br />
  $.ajax({ <br />
   type: "GET", <br />
   url: "http://10.0.8.10/feeds/rss/mwsu.edu/news-feed-2/", <br />
   dataType: "xml", <br />
   success: function(xml) { <br />
    xml = getLatest({xml:xml}); <br />
    $.each(xml,function(){ <br />
     var title = $(this).find('title').text(); <br />
     var link = $(this).find('link').text(); <br />
     var date = $(this).find('pubDate').text(); <br />
     $('<li></li>').html('<a href="'+link+'">'+title+'</a>').appendTo(".news"); <br />
    }); <br />
   } <br />
  }); <br /><br />
  function getLatest(options) { <br />
   var defaults = {count:5, attr:'dc:date'}; <br />
   var settings = $.extend({},defaults, options); <br />
   var oxml = $.grep( <br />
    $('item', settings.xml).get().sort(function(a,b){ <br />
     return Date.parse($(settings.attr,b).text()) > Date.parse($(settings.attr,a).text()); <br />
    }), <br />
    function(v,i) { return i < settings.count; } <br />
   ); <br />
   return oxml; <br />
  } <br />
 }); <br />
</script>   

When you used what Kemal suggested, did you just put the non-breaking space in the LI or did you copy exactly what he had? Just checking because his doesn’t include the class in it but your code is looking for a class on the UL.

My other suggestion would be to throw a breakpoint on the xml = getLatest… line using the Script tab in FireBug or Chrome and see that the XML is coming back. If so, throw a bp on the $(’

')…appendTo and see if it is hitting that point.

Nothing in your script appears to be relying on the LI in the UL. That looks to be merely a placeholder for you. You might even want to call $(‘ul.news’).empty() before calling the append to clear out the blank LI placeholder.

Okay, so I have modified the code and i put a break point at the xml-getLatest line and it never does anything.

This is what my new code looks like.

<script type="text/javascript"> <br />
 $(document).ready(function(){
<br />
  $.ajax({ <br />
   type: "GET", <br />
   url: "http://10.0.8.10/feeds/rss/mwsu.edu/news-feed-2/", <br />
   dataType: "xml", <br />
   success: function(xml) { <br />
    xml = getLatest({xml:xml}); <br />
    $.each(xml,function(){ <br />
     var title = $(this).find('title').text(); <br />
     var link = $(this).find('link').text(); <br />
     var date = $(this).find('pubDate').text(); <br />
     $('<li></li>').html('<a href="'+link+'">'+title+'</a>').appendTo(".news"); <br />
    }); <br />
   } <br />
  }); <br />
  function getLatest(options) { <br />
                                      $('ul.news').empty();l <br />
   var defaults = {count:5, attr:'dc:date'}; <br />
   var settings = $.extend({},defaults, options); <br />
   var oxml = $.grep( <br />
    $('item', settings.xml).get().sort(function(a,b){ <br />
     return Date.parse($(settings.attr,b).text()) > Date.parse($(settings.attr,a).text()); <br />
    }), <br />
    function(v,i) { return i < settings.count; } <br />
   ); <br />
   return oxml; <br />
  } <br />
 }); <br />
</script>   

The blank LI disappears with no issues.

I forgot to say that the 10.0.8.10 is the internal ip address that has the xml feeds on it.

Matt,

Is the character at the end of the line under the func. getLatest just a typo or misprint in the code paste or is that in your local code as well?

That was just a typo when I was typing that in on the forum.

Okay, so after some time today just digging and digging, I finally found the culprit. 1) I had a second version of jquery loading on top of the version Percussion was loading and then 2) supersubs was throwing lots of errors so I checked the page for it and the author recently updated the code. The last update for it was in 2008.

I’m not sure if the 2nd item had anything to do with it but my list is now working. Thanks for the help Daved and Kemai.