Hi Howard, my custom autocomplete was built around the old version of the
typeahead script. Anyhow, I'm trying to update my script to work with the
new typeahead libarary, but running into a little problem. Considering you
just finished up building the new autocomplete, perhaps it may still be
fresh in your mind and may be able to help me.

My original autocomplete worked like a select menu and would allow you to
pass in additional parameters for additional filtering. For example, year,
make, model, trim. If you type in a year, when you get to the make, it only
showed makes for that year. My autocomplete mixen takes an additional
parameter, "filterId", or "year", or "year,make" etc. When it gets passed
back to my custom-autocomplete script, I put the id's into an array and
ultimately build a little json object containing filter field Id's and
field value's along with the focused field id and filter id. I then use
JSON.stringify and attempt to "return extendURL(uri, stringify)", however
it fails sending back my JSON.stringify object.

Do you know how to return a JSON.stringify object?

Here's my code snippet.

sample json object.

{
    "t:jsonStringField": {
        "name": "model",
        "value": "fusion"
    },
    "t:jsonStringFilter": [
        {
            "name": "year",
            "value": "2009"
        },
        {
            "name": "make",
            "value": "ford"
        }
    ]
}


<input id="year" value="2013"/><input id="make" filterBy="year"
value="ford"/><input id="model" filterBy="year,make" value="fusion"/>


 init = function(spec) {
        var $field = $("#" + spec.id),
                filterIdArray = [];

        if (typeof spec.filterId !== 'undefined') {
            filterIdArray = spec.filterId.split(',');
        }

 return $field.typeahead({
    replace: function(uri, query) {
       var params = {};
           params["t:jsonStringField"] = searchField(spec.id, query);
           params["t:jsonStringFilter"] = searchFilter(filterIdArray);

       var stringify = JSON.stringify(params);

       //I'm trying to pass back this stringified json object.
       return extendURL(uri, stringify);
    }
  }

    //The current search input
    searchField = function(fieldId, query) {
        return {name: fieldId, value: query};
    };

    //Additional fields used to create where clause within searchField
    searchFilter = function(filterIdArray) {
        var array = [];

        //Field Id's and any fields being filtered by
        for (var i = 0; i < filterIdArray.length; i++) {
            var value = $("#" + filterIdArray[i]).val(),
                 name = filterIdArray[i];

            array.push({name: name, value: value});
        };

        return array;
    };

I end up getting the following error which I believe is a result of how the
URL is being generated. Do you happen to know why the URL may be generated
like this?

"NetworkError: 500 Internal Server Error -
/TapDemo/sell/createlisting.year:autocomplete?category=aircraft&0={&1=%22&2=t&3=:&4=j&5=s&6=o&7=n&8=S&9=t&10=r&11=i&12=n&13=g&14=F&15=i&16=e&17=l&18=d&19=%22&20=:&21={&22=%22&23=n&24=a&25=m&26=e&27=%22&28=:&29=%22&30=y&31=e&32=a&33=r&34=%22&35=,&36=%22&37=v&38=a&39=l&40=u&41=e&42=%22&43=:&44=%22&45=5&46=%22&47=}&48=,&49=%22&50=j&51=s&52=o&53=n&54=S&55=t&56=r&57=i&58=n&59=g&60=F&61=i&62=l&63=t&64=e&65=r&66=%22&67=:&68=[&69=]&70=}"




On Wed, Sep 11, 2013 at 6:24 PM, Howard Lewis Ship <hls...@gmail.com> wrote:

> Some module, hopefully not an of the t5/core modules, has a dependency on
> "bootstrap" ... but the Boostrap JS has been broken up into a number of
> small modules, such as "bootstrap/modal".  The modules don't export
> anything, but can be declared as module dependencies to ensure they are
> loaded.
>
>
> On Wed, Sep 11, 2013 at 3:10 PM, George Christman
> <gchrist...@cardaddy.com>wrote:
>
> > Hi Guys, I upgraded my test project to 5.4.17 and noticed it broke my
> > custom autocompletes, so I seen Howard was releasing a preview release
> for
> > version 5.4.20. Anyhow I'm receiving the following script error which I
> > believe is the reason my autocompletes are breaking. Anybody know how to
> > fix this?
> >
> > "NetworkError: 404 /asset.gz/module/bootstrap.js -
> > http://localhost:8080/TapDemo/asset.gz/module/bootstrap.js";
> > bootstrap.js
> > RequireJS error: scripterror: Script error for: bootstrap
> > http://requirejs.org/docs/errors.html#scripterror, modules bootstrap
> > level(message="RequireJS error: script...rror, modules
> > bootstrap")console.js
> > (line 100)
> > onError(err=
> > Error: Script error for: bootstrap
> > http://requirejs.org/docs/errors.html#scripterror
> >
> > var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' +
> id);
> >
> > )console.js (line 127)
> > onError(err=
> > Error: Script error for: bootstrap
> > http://requirejs.org/docs/errors.html#scripterror
> >
> > var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' +
> id);
> >
> > , errback=undefined)require-2.1.8.js (line 536)
> > onScriptError(evt=error )require-2.1.8.js (line 1666)
> >
> > consolefn.call(console, message);
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>



-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York

Reply via email to