SHOW:
|
|
- or go back to the newest paste.
| 1 | <!DOCTYPE html> | |
| 2 | - | <html> |
| 2 | + | <html> |
| 3 | - | <head> |
| 3 | + | <head> |
| 4 | - | <title>prueba</title> |
| 4 | + | <title>prueba</title> |
| 5 | - | <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> |
| 5 | + | <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> |
| 6 | - | <script src="http://code.jquery.com/jquery-1.9.1.js"></script> |
| 6 | + | <script src="http://code.jquery.com/jquery-1.9.1.js"></script> |
| 7 | - | <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> |
| 7 | + | <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> |
| 8 | - | <link rel="stylesheet" href="/resources/demos/style.css" /> |
| 8 | + | <link rel="stylesheet" href="/resources/demos/style.css" /> |
| 9 | - | <script> |
| 9 | + | <script> |
| 10 | - | $(function() {
|
| 10 | + | $(function() {
|
| 11 | - | |
| 11 | + | |
| 12 | - | $("#tags").autocomplete({
|
| 12 | + | $("#tags").autocomplete({
|
| 13 | - | source : function( request , response ){
|
| 13 | + | source : function( request , response ){
|
| 14 | - | var url = "autocomplete.php"; |
| 14 | + | var url = "autocomplete.php"; |
| 15 | - | $.post(url, { 'search' : request.term }, response, 'json');
|
| 15 | + | $.post(url, { 'search' : request.term }, response, 'json');
|
| 16 | - | }, |
| 16 | + | }, |
| 17 | - | select: function( event, ui ) {
|
| 17 | + | select: function( event, ui ) {
|
| 18 | - | $("#tags").val(ui.item.name);
|
| 18 | + | $("#tags").val(ui.item.name);
|
| 19 | - | //$('#hidden_tag').val(ui.item.name);
|
| 19 | + | //$('#hidden_tag').val(ui.item.name);
|
| 20 | ||
| 21 | - | return false; |
| 21 | + | return false; |
| 22 | - | } |
| 22 | + | } |
| 23 | - | }).data("ui-widget")._renderItem = function(ul, item) {
|
| 23 | + | }).data("ui-autocomplete")._renderItem = function(ul, item) {
|
| 24 | - | return $("<li>").append( "<a>" + item.name + "</a>" ).appendTo( ul );
|
| 24 | + | return $("<li>").append( "<a>" + item.name + "</a>" ).appendTo( ul );
|
| 25 | - | }; |
| 25 | + | }; |
| 26 | - | |
| 26 | + | }); |
| 27 | - | |
| 27 | + | </script> |
| 28 | - | |
| 28 | + | </head> |
| 29 | - | |
| 29 | + | <body> |
| 30 | - | |
| 30 | + | <div class="ui-widget"> |
| 31 | - | }); |
| 31 | + | <input type="hidden" id="hidden_tag" name="hiddentag" value=""> |
| 32 | - | </script> |
| 32 | + | <label for="tags2">Tags: </label> |
| 33 | - | </head> |
| 33 | + | <input type="text" id="tags" /> |
| 34 | - | <body> |
| 34 | + | </div> |
| 35 | - | <div class="ui-widget"> |
| 35 | + | </body> |
| 36 | - | <input type="hidden" id="hidden_tag" name="hiddentag" value=""> |
| 36 | + | </html> |
| 37 | - | <label for="tags2">Tags: </label> |
| 37 | + | |
| 38 | - | <input id="tags" /> |
| 38 | + | <!-- y el autocomplete.php --> |
| 39 | - | </div> |
| 39 | + | |
| 40 | - | |
| 40 | + | <?php |
| 41 | - | </body> |
| 41 | + | $data=array(array('name'=>'prueba'), array('name'=>'prueba2'));
|
| 42 | - | </html> |
| 42 | + | echo json_encode($data); |
| 43 | - | <? |
| 43 | + | ?> |