Skip to content

Instantly share code, notes, and snippets.

@wemakeweb
Created August 7, 2012 15:31
Show Gist options
  • Save wemakeweb/3286427 to your computer and use it in GitHub Desktop.
Save wemakeweb/3286427 to your computer and use it in GitHub Desktop.
CORE.Scripts.register('/widget/weather/0.01/js/input.js', {
widget : {
resize : {
aspectRatio : true
}
},
onresize : function(){
},
start : function(dialog){
var self = this;
var frame_widget_id = $("#config-widget").attr("data-widgetId");
var locationList = [];
$('input:text[name=city]').autocomplete({
source : function(content, callback){
$.ajax({
url : '/folien/folie/widget/' + frame_widget_id + '?action=city_acomp',
type : 'post',
dataType : 'json',
data : {
search_string : $('#city').attr('value')
},
success : function(response){
if(response.data.result){
self.suggestionList = response.data.suggestions
var nameList = [];
self.suggestionList.forEach(function(location){
nameList.push(location.name);
})
callback(nameList);
}
}
});
},
select : function(event, ui){
var item = ui.item;
var breaker = false;
self.suggestionList.forEach(function(location){
if(breaker === false && location.name == item.value){
$('input:hidden[name=link]').attr('value', location.link);
breaker = true;
}
});
}
});
},
stop : function(dialog){
$('#city').unbind('keypress');
$('form', dialog).unbind('click');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment