Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Jquery mobile

$
0
0
Hi All,

First off, I'd like to say this is a fantastic library. I've just started using it and have been really impressed with its functionality thus far. For what its worth, I am also relatively new to Jquery and Jquery mobile, so apologies for the sloppy code.

I am running into a strange issue while trying to use SPServices with the Jquery mobile library.

I have two SPServices requests wrapped the within the following functions:

$(document).on("pageinit", function() {
$('#list li').live('click', function() {

The first writes a ul list based on entries from pulled Sharepoint. The second generates some dynamic html code and pulls data from Sharepoint based on the clicked list item.

They both work perfectly.

Now I am trying to click on a third, dynamically generated button and make a SPServices call. However, when I do this, for some reason SPServices call is returning nothing. See my code below. The '$('#like').live' function is returning blank, but the other two work fine. Any idea?
<script type="text/javascript" language="javascript">

$('#like').live('click', function() { alert($().SPServices.SPGetCurrentSite()); });

$(document).on("pageinit", function() {

$().SPServices({
    operation: "GetListItems",
    async: false,
    webURL: "/sites/rolebasedlearning/NEIMCOP",
    listName: "SignupList",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {       
      var liHtml = "<li id='" + $(this).attr("ows_ID") + "'><a href='#popup' data-role='button' data-rel='dialog' data-transition='pop'>" + $(this).attr("ows_Title") + 

"</a></il>";
        $("#list").append(liHtml);
    $("#list").listview("refresh");
    $("#one").trigger("create");
      });
    }
  });

});


$('#list li').live('click', function() {

var listid = $(this).attr("id");

alert('Selected Name=' + listid);

$().SPServices({
    operation: "GetListItems",
    async: false,
    webURL: "/sites/rolebasedlearning/NEIMCOP",
    listName: "SignupList",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='University' /><FieldRef Name='Name' /><FieldRef Name='GradYear' /><FieldRef Name='Major' 

/><FieldRef Name='GradYear' /><FieldRef Name='Minor' /><FieldRef Name='Like' /></ViewFields>",
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Text'>" + listid + "</Value></Eq></Where></Query>",
    completefunc: function (xData, Status) { 
    alert(xData.responseText);
    $(xData.responseXML).SPFilterNode("z:row").each(function() {
    var response = "<h2>" + $(this).attr('ows_Title') + "</h2>" + "<p>Major: " + $(this).attr('ows_Major') + "</p><p>Minor: " + $(this).attr('ows_Minor') + 

"</p><p>Grad Year: " + $(this).attr('ows_GradYear') + "</p><a id='like' data-role='button' data-inline='true' data-icon='back' id='" + listid + "'>" + $(this).attr

('ows_Like') + "</a>";
    $('#popup [data-role="content"]').html(response);
    $('#popup').trigger('create');
    });
    }
  });
});

</script>

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>