Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I defined a list where a Summary list is a coloum, in my javascript code i want to read the values of the links one by one...

sliderText = listItem.get_item('Description0');
sliderTitle = listItem.get_item('Title');
sliderLinks = listItem.get_item('SummaryLinks');

So the value of sliderLinks now is:

<div title="_schemaversion" id="_3">
  <div title="_links">
    <div title="_link">
      <span title="_title">Home</span>
      <span title="_order">1</span>
      <span title="_begincolumn">True</span>
      <span title="_linkurl">
        <a href="http://gmail.com">http://gmail.com</a>
      </span>
    </div>
  </div>
  <div title="_view">
    <span title="_columns">1</span>
    <span title="_linkstyle"></span>
    <span title="_groupstyle"></span>
  </div>
</div>

in the COM, isn't there functions to get the value of the URL and title instead of this HTML code?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Unfortunately the only thing CSOM gets from the server is the HTML (you can see that if you use fiddler while executing the request).

So you'll have to dig the values out of the html. If you've included jQuery you can do something like this:

    var sl = jQuery('<div></div>').html(listItem.get_item("SummaryLinks"));
    sl.find('div[title="_link"]').each(function (index, element) {
        var title = $(this).find('span[title="_title"]').text();
        var url = $(this).find('span[title="_linkurl"]').text();
        alert(title + '\n' + url);
    });
share|improve this answer
    
+1 for mentioning fiddler :) –  Haadka Apr 8 '12 at 10:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.