Reputation: 14960
I want to pass an object in javascript. But i am getting an error javascript:callbackCredits(1,dotsContainer_credits); is undefined
My code is as follows:
var dotSlideCredits = {
show : 3,
width : 430,
functionName : "callbackCredits",
title: "title",
itemId: "#s_credit"
}
var test = {
data[]
}
$(document).ready(function(){
dynamicList(dotSlideCredits);
}
function dynamicList(dotSlide){
var divItems = "dotsContainer_"+dotSlide.title;
test.data.push({title: dotSlide.title+[i], callBack: "javascript:"+dotSlide.functionName+"("+i+","+divItems+");"});
}
function callbackCredits(current, container){
var prev = $("#previousCredit").val();
slideShow(current, prev, container);
$("#previousCredit").attr("value", current);
}
Upvotes: 2
Views: 136
Reputation: 146630
I think the error message is pretty descriptive. You've added a bogus "javascript:"
prefix to your function name. Remove it.
Upvotes: 0
Reputation: 991
what i would do probably is something like that :
var dotSlideCredits = {
show : 3,
width : 430,
itemId: "#s_credit",
functionName: function(current, container){
callbackCredits(current,container);
}
}
function callbackCredits(current, container) {
var prev = $("#previousCredit").val();
slideShow(current, prev, container);
$("#previousCredit").attr("value", current);
}
and then simply call dotSlide.functionName(i,divItems);
(not tested bout should be something close to that)
Upvotes: 1
Reputation: 5917
Are you sure the callBack property isn't a function? It probably should be
E.g.:
test.data.push({
title: dotSlide.title+[i],
callBack: function () {
dotSlide.functionName(i,divItems);
}
});
does that make sense?
Upvotes: 1