Thanks Howard. On Tue, Jun 18, 2013 at 11:54 AM, Howard Lewis Ship <hls...@gmail.com>wrote:
> You've got it. Real documentation coming Real Soon Now. > > > On Tue, Jun 18, 2013 at 8:30 AM, George Christman > <gchrist...@cardaddy.com>wrote: > > > I believe I figured this out, if someone could confirm I'm doing this > > correctly, I'd appreciate it. > > > > I added the following to the resource package, > > META-INF/modules/custom-autocomplete.js > > > > I removed @Import(library="context:js/custom-autocomplete.js") > > > > and changed the require to > > jsSupport.require("custom-autocomplete").with(spec); > > > > It does appear to work, but I'd like to be sure it's being done > correctly. > > Thanks > > > > > > > > > > On Tue, Jun 18, 2013 at 11:06 AM, George Christman > > <gchrist...@cardaddy.com>wrote: > > > > > Hello everyone, I'm trying to familiarize myself with some of t5.4. > I've > > > been trying to build a sample mixin based off from the Tap > autocomplete, > > > but seem to have stumbled on JavaScriptSupport require. I'm not sure > how > > to > > > import my custom js and call the initialize method while still being > able > > > to pass in my json parameters. > > > > > > What I've tried. > > > > > > .class > > > > > > @Import(library="context:js/custom-autocomplete.js") > > > public class CustomAutocomplete { > > > > > > @Environmental > > > private JavaScriptSupport jsSupport; > > > > > > void afterRender() { > > > Link link = resources.createEventLink(EVENT_NAME); > > > > > > JSONObject spec = new JSONObject("id", field.getClientId(), > > > "url", link.toString()).put("minChars", minChars); > > > > > > jsSupport.require("js/custom-autocomplete").with(spec); > > > } > > > > > > > > > .js > > > > > > define(["./dom", "./ajax", "jquery", "bootstrap"], function(dom, ajax, > > $) { > > > var doLookup, exports, init; > > > doLookup = function($field, url, query, process) { > > > $field.addClass("ajax-wait"); > > > return ajax(url, { > > > parameters: { > > > "t:input": query > > > }, > > > success: function(response) { > > > $field.removeClass("ajax-wait"); > > > return process(response.json.matches); > > > } > > > }); > > > }; > > > init = function(spec) { > > > var $field; > > > $field = $(document.getElementById(spec.id)); > > > return $field.typeahead({ > > > minLength: spec.minChars, > > > source: function(query, process) { > > > doLookup($field, spec.url, query, process); > > > } > > > }); > > > }; > > > return exports = init; > > > } > > > > > > I receive the following error. > > > > > > "NetworkError: 404 /asset.gz/module/js/custom-autocomplete.js - > > > > http://localhost:8080/TapDemo/asset.gz/module/js/custom-autocomplete.js" > > > > > > Could someone help me to understand what I'm may be doing wrong? > Thanks. > > > > > > > > > -- > 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 >