Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Re: Polymorphism on YUI datasource (autocomplete related)

Expand Messages
  • Satyam
    I don t think you would need this at all since DataSource is already a factory that can deliver any of the other specific DataSources. Pre-2-7, there was only
    Message 1 of 4 , Jun 2, 2009
    • 0 Attachment
      I don't think you would need this at all since DataSource is already a
      factory that can deliver any of the other specific DataSources.
      Pre-2-7, there was only DataSource, which was a very complex object. In
      2.7 it was split into several separate components but a single
      DataSource entry point was kept for backward compatibility, and it will
      produce instances of any of the specific types of DataSources.
      DataSource itself is not derived from DataSourceBase, though the objects
      it returns are.

      Satyam


      aashay escribió:
      > Hi kennyth01,
      >
      > I am trying to do similar thing as yours and was wondering if you found the way to do so. Please reply.
      >
      > Thanks
      > Aashay
      >
      > --- In ydn-javascript@yahoogroups.com, "kennyth01" <kennyth01@...> wrote:
      >
      >> Any hints on this anyone?
      >>
      >> --- In ydn-javascript@yahoogroups.com, "kennyth01" <kennyth01@> wrote:
      >>
      >>> Hi,
      >>>
      >>> I've created a generic DataSourceBase instance so that I can be able to
      >>> change its type as ScriptNode, Local, etc (vice versa) but apparently it
      >>> doesn't work. Am I doing the right thing? Here's a sample:
      >>>
      >>> //GLOBAL OBJECTS
      >>> var oDS = null;
      >>> var oAC = null;
      >>>
      >>> //suppose i have an initialize method
      >>> function init () {
      >>>
      >>> oDS = new YAHOO.util.DataSourceBase("");
      >>> oAC = new YAHOO.widget.AutoComplete("myInput",
      >>> "myAutocompleteContainer", oDS);
      >>>
      >>> // other codes here . . .
      >>> }
      >>>
      >>>
      >>> //I want to update my data source to ScriptNode for example
      >>> updateDStoScriptNode() {
      >>> oDS.dataType = YAHOO.util.DataSourceBase.TYPE_SCRIPTNODE;
      >>> oDS.liveData = "http://getJSONfeed.com/etchetera";
      >>> oDS.responseType = YAHOO.util.DataSourceBase.TYPE_JSON;
      >>>
      >>>
      >>> }
      >>>
      >>> //I want to update my data source to Local for example
      >>> updateDStoLocal() {
      >>> var sample = ["anna", "banana", "cassandra"];
      >>> oDS.dataType = YAHOO.util.DataSourceBase.TYPE_LOCAL;
      >>> oDS.liveData = sample;
      >>> oDS.responseType = YAHOO.util.DataSourceBase.TYPE_JSARRAY;
      >>> }
      >>>
      >>>
      >>>
      >>> Suppose I have two buttons, One button is to change the DS to ScriptNode
      >>> and calls the updateDStoScriptNode, and the other is to change the DS to
      >>> Local and calls the updateDStoLocal.
      >>>
      >>>
      >>> Any suggestions? Thanks!
      >>>
      >>>
      >
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - www.avg.com
      > Version: 8.5.339 / Virus Database: 270.12.49/2149 - Release Date: 06/01/09 17:55:00
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.