Hi,
I have created a control, I associate my control with a DIV element
function pageLoad() {
$create(Homepage.Autocomplete, null, null, null, $get("Test"));
}
<div id="Test"></div>
The control's name is Autocomplete, and it has a public method (function): load(text, count){} that calls WebService method.
My question: How do I call that load(text, count) method from javascript on my page?
function foo() {
Homepage.Autocomplete.load("some text", 10);
}
it doesn't work. Debugger sees Homepage.Autocomplete, but when I mouse over "load", it shows undefined.
Any idea how to do that correctly?
Thanks.
Below is the code for the control Autocomplete.js (I cleaned it for sake of simplicity):
Type.registerNamespace("Homepage");
Homepage.Autocomplete = function(element) {
Homepage.Autocomplete.initializeBase(this, [element]);
}
Homepage.Autocomplete.prototype = {
initialize: function() {
Homepage.Autocomplete.callBaseMethod(this, "initialize");
},
dispose: function() {
Homepage.Autocomplete.callBaseMethod(this, "dispose");
},
load: function(text, count) {
WebService.GetSuggestions(text, count, this.oncompleted, this.onfailed, this);
},
oncompleted: function(data, control) {
},
onfailed: function(error, control) {
}
}
Homepage.Autocomplete.registerClass("Homepage.Autocomplete", Sys.UI.Control);
if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();