SPServices not working

rss

Posted by gleegeld - Apr 5 ’16 at 05:36

Hello,

I added watermark text using the example from the forum (works great) however adding the watermark text has cause SPServices to no longer work. What do I need to change to get SPServices working again?

Thanks

 

window.$ = $;
window.jQuery = $;

RegisterSod('watermark.js', '/SiteAssets/js/jquery.watermark.min.js');
LoadSodByKey('watermark.js', null, true);

fd.field('Extension').control()._el().find('textarea').watermark('Example: ');


fd.field('Status').control()._el().find('textarea').watermark('Examples: ');

 

var query = "<Query><Where><Eq><FieldRef Name='Author' LookupId='TRUE' /><Value Type='Integer'><UserID Type='Integer'/></Value></Eq></Where></Query>";
window.$().SPServices({
operation: "GetListItems",
async: false,
listName: "Closing",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLRowLimit: 1,
CAMLQuery: query,
completefunc: function (xData, Status) {
totalItems = parseFloat(window.$(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount"));
alert('here ' + totalItems);
if (totalItems > 0) {
window.$(xData.responseXML).SPFilterNode("z:row").each(function () {

});
}
}
});

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 7 months 4 days
    #1 by rostislav Apr 6 ’16 at 07:30

    Your problem seems to be the fact that you're utilizing two jquery functions on your page.

    Easiest, but a hacky thing to do is the following.

    Try doing this:

    var spServicesjQuery = window.$ || window.jQuery;
    
    window.$ = $;
    window.jQuery = $;
    
    RegisterSod('watermark.js', '/SiteAssets/js/jquery.watermark.min.js');
    LoadSodByKey('watermark.js', null, true);
    
    fd.field('Extension').control()._el().find('textarea').watermark('Example: ');
    
    
    fd.field('Status').control()._el().find('textarea').watermark('Examples: ');
    
    
    var query = "";
    
    spServicesjQuery().SPServices({
    	....
    });
    

    But best thing still would be to edit the watermark script so that it utilizes Plumsail.FD.jQuery.

  • gleegeld
    Member
    Member for: 6 years 5 months 10 days
    #2 by gleegeld Apr 7 ’16 at 02:05

    The changes you suggested give me an error

    Object doesn't support property or method 'SPFilterNode'

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 7 months 4 days
    #3 by rostislav Apr 8 ’16 at 06:19

    [#2]:

    Replace

    window.$(xData.responseXML)
    

    with

    spServicesjQuery(xData.responseXML)
    
Displaying 1 to 3 of 3 messages