Button click jquery function is not calling SP services function in CEWP

Feb 17, 2014 at 5:27 AM
Edited Feb 17, 2014 at 5:28 AM
I have call an Sp services function in button click but it is not working here this is my code
$("input[id$='FormControl0_V1_I1_B8']").click(function(){
        getSkill();
    }); 
function getSkill(){ 
var skill = []; 
$().SPServices({ 
operation: "GetListItems", 
listName: "lookup",
CAMLViewFields: "", 
CAMLQuery: "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>SKILL</Value></Eq></Where></Query>",
async: false, 
completefunc: function (xData, Status) { 
$(xData.responseXML).SPFilterNode("z:row").each(function() { 
skill.push({label:$(this).attr("ows_Column2"),value:$(this).attr("ows_ID")});    
}); 
} 
}); 

$("input[id$='FormControl0_V1_I1_T7']").autocomplete({ 
source: skill, 
minLength: 2, 
});
can you please help me.
Coordinator
Feb 17, 2014 at 1:44 PM
What's not working?

M.
Feb 18, 2014 at 2:34 AM
$("input[id$='FormControl0_V1_I1_B8']").click(function(){
    getSkill();
}); 
on this click function the getSkill() function is not getting called.. so this not working.
Coordinator
Feb 18, 2014 at 4:22 AM
Are you getting an error? Have you tried debugging by stepping through your code?

You don't have your code wrapped in a $(document).ready(), so the input element may not be in the page yet when it runs.

M.
Feb 18, 2014 at 4:48 AM
ya i have tried using $(document).ready() too, it is not calling the getSkill(), it is not showing any erro msg too.
Coordinator
Feb 18, 2014 at 1:10 PM
Well, your selector for the input element could be wrong, so the click even may never happen. Add an alert in there so that you can be sure it's firing.

M.
Feb 19, 2014 at 11:33 AM
Well i have tried the alert message is not displaying, this function is not getting fire may i know the possible solution...
Coordinator
Feb 19, 2014 at 11:56 AM
You'll need to do some debugging. I'd check the id of the input element and make sure your selector is correct, as I've mentioned above.

M.