javascript - Access $(this) DOM element from within jQuery Autocomplete Widget Ajax call -
In the code below (coffeespot), the AJAX call for jQuery's autocomplete data source, 5 lines of code But, I'm passing 2 paramours - duration: and ll: for: I'm trying to be $ (this) to be a DOM element. Was applied to autocomplete. In this case its $ ('[type = "text"] [name * = "[location]"]') I need to reference that on the 5 line with the DOM element especially ($ this). However, I believe that 'this' is something else in the radius that does not have a DOM element, will someone tell me what I need to do? Autocomplete (source: (request, response) - & gt; $ .jax url:
$ ('[type =' 'text'] [name * = "[location]"] ' ). Data ('auto-complete') data: {period: request.term, ll: $ (this) .siblings ('$ [' type = "text"] [name * = "[location]"] '. [Name * = "[geocode_location]"]')} contentType: "application / json; charset = utf-8" success: (data) -> feedback $ .map (data, (object) -> gt; ; Value: Item .value label: item.label address: item.address) Focus: (Event, UI) -> Event.preventDefault () $ (this) .value ui.item.label Choose: (Event, UI ) -> Event .preventDefault () $ (this) .value ui.item.label $ (this) .siblings ('[name * = "[foursquare_ Id] "] '). Val ui.item.value) .data (" autocomplete ") ._renderItem = (ul, item) - & gt; $ ("& Lt; li & gt;"). Data ("item.autocomplete", item) .append ("& lt; a & gt;" + item.label + "& lt; br & gt;" + item.address + "& lt; / a & gt; "). App add ul
I can not tell you anything about the capswap, but < Strong> this.element element should return (this is a jQuery-object) Then it should be:
Ll : This.element.siblings ('[name * =' [geocode_location] "] ') But this will not work, because siblings gives a jQuery-object and did not pass As a request-parameter
Comments
Post a Comment