Created
November 13, 2013 11:17
-
-
Save pablomp/7447436 to your computer and use it in GitHub Desktop.
Combo Select2 con valores dinámicos desde un JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$j('#e1').select2({ | |
placeholder: "Seleccione municipio", | |
allowClear: true, | |
ajax: { | |
url: '/vct/json/jsonMunicipios.php', | |
dataType: 'json', | |
data: function (term) { | |
return { | |
term: term | |
}; | |
}, | |
results: function (data) { | |
var results = []; | |
$j.each(data.results, function(index, item){ | |
results.push({ | |
id: item.id, | |
text: item.text, | |
coordendadaLat: item.coordinates[1], | |
coordendadaLong: item.coordinates[0] | |
}); | |
}); | |
return { | |
results: results | |
}; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment