locked
getting data from a sharepoint list using JQuery RRS feed

  • Question

  • I am new at jquery/sharepoint so I hope this is a simple question for you gurus. I am looking at somebody else code and I cannot understand how it works (magic maybe?).
    In the sharepoint page I am "decoding",  the JQuery code seems to get the items to be displayed from a sharepoint list. Then Jquery shows them in a table coded in the same sharepoint page. 
    Part of the table's code is
    ...<tr><td><strong>Name:</strong>
    </td><td id="OffName"></td></tr>
    <tr><td><strong>T POC:</strong></td><td id="TPOC"></td></tr>...
    It works fine (and that's what I do not understand!!!!). I believe that <td id="OffName"></td> tells the browser to insert in that cell the value for item id="OffName"
    The Jquery section of the code says:
    //here it defines an arrays
    var newarr = $.makeArray();
    //set the field in the array (not sure why he needs to put the value in an array)
    $("#OffName").text(newarr[1]); 

    The question is how JQuery understand what is OffName? Is the id=OffName automatically generated by SharePoint or was the id added by the programmer some where in the list? Is there a way to edit the item id in a list's element so JQUery can parse it? I am looked everywhere for something like <div id="OffName"> but I cannot find it.
    So I am lost...anybody can help?
     
    Thanks
     
    Luca
    Saturday, October 1, 2011 1:35 PM

Answers

  • result of $(...) operation is set of dom elements which match criteria passed inside selector. Syntax "#foo" means that we want to get all dom elements which have id="foo". Also you can e.g. retrieve elements by css class name $(".bar") - it will return all elements which have attribute class="bar". All these examples are part of jquery syntax, nothing more.
    Blog - http://sadomovalex.blogspot.com
    CAML via C# - http://camlex.codeplex.com
    • Proposed as answer by Guangming Wednesday, October 5, 2011 2:58 PM
    • Marked as answer by Qiao Wei Thursday, October 13, 2011 9:45 AM
    Monday, October 3, 2011 8:06 PM

All replies

  • I would assume that JQuery links data with the table using the id. More details on what you have may help.
    Monday, October 3, 2011 5:15 PM
  • result of $(...) operation is set of dom elements which match criteria passed inside selector. Syntax "#foo" means that we want to get all dom elements which have id="foo". Also you can e.g. retrieve elements by css class name $(".bar") - it will return all elements which have attribute class="bar". All these examples are part of jquery syntax, nothing more.
    Blog - http://sadomovalex.blogspot.com
    CAML via C# - http://camlex.codeplex.com
    • Proposed as answer by Guangming Wednesday, October 5, 2011 2:58 PM
    • Marked as answer by Qiao Wei Thursday, October 13, 2011 9:45 AM
    Monday, October 3, 2011 8:06 PM