I've got a user control which lets users provided their own script names that are called by the control on specific events.
I have the following code:
initialize : function()
{
// Call the base initialize method
Point74.WebAutoComplete.callBaseMethod(this, 'initialize');
$(document).ready(
Function.createDelegate(this, this._onDocumentReady)
);
},
_onDocumentReady : function()
{
var me = this;
$("#" + me.get_id()).autocomplete(me.get_ashxAddress(),
{
formatItem: function(item)
{
return eval(me.get_formatFunction() + "(" + item + ");");
}
}
).result(me.get_selectFunction());
}
me.get_formatFunction contains the name of a function, i.e. "FormatItem". This example is currently using eval, which I do not want to use... plus this example doesn't work anyway, but I thought I'd show what I'm trying to get at.
In the example above, I get a value undefined error as 'item' is a string array and eval tries to convert it into one long string.
How can I achieve this functionality any still pass through 'item' as a string array to the named function?
If passing named functions is a bad idea, are there any alternatives?
This is how my control is declared:
<p74:WebAutoComplete runat="server" ID="ato_Test" AshxAddress="WebServices/SearchService.ashx"
FormatFunction="formatItem" SelectFunction="searchSelectedMaster" />