- How to submit form onclick like google's autosuggest with jqueryui?
- <script type="text/javascript">
- $(document).ready(function() {
- $.widget( "custom.catcomplete", $.ui.autocomplete, {
- _renderMenu: function( ul, items ) {
- var self = this,
- currentCategory = "";
- $.each( items, function( index, item ) {
- if ( item.category != currentCategory ) {
- ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
- currentCategory = item.category;
- }
- self._renderItem( ul, item );
- });
- },
- select: function(event, ui) {
- $("input#autocomplete_text").val(ui.item.value);
- $("#autocomplete_form").submit();
- }
- });
- $( "#autocomplete_text" ).catcomplete({
- delay: 0,
- source: function(request, response) {
- $.ajax({ url: "<?php echo site_url('autocomplete/suggestions'); ?>",
- data: { term: $("#autocomplete_text").val()},
- dataType: "json",
- type: "POST",
- success: function(data){
- response(data);
- }
- });
- }
- });
- });
- </script>
- <form id="autocomplete_form" name="input" action="autocomplete/redirect" method="post">
- <input size="38" type="text" id="autocomplete_text" name="autocomplete_text" value="İlan kodu, kategori, ilan veya emlakçı ara" />
- <input type="hidden" id="data" name="data" value="0" />
- <input class="submit-button" type="submit" value=" EMLAK ARA " />
- </form>
- <script type="text/javascript">
- $(document).ready(function() {
- $.widget( "custom.catcomplete", $.ui.autocomplete, {
- _renderMenu: function( ul, items ) {
- var self = this,
- currentCategory = "";
- $.each( items, function( index, item ) {
- if ( item.category != currentCategory ) {
- ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
- currentCategory = item.category;
- }
- self._renderItem( ul, item );
- });
- }
- });
- $( "#autocomplete_text" ).catcomplete({
- delay: 0,
- select: function(event, ui) {
- $("#autocomplete_form").submit();
- },
- source: function(request, response) {
- $.ajax({ url: "<?php echo site_url('autocomplete/suggestions'); ?>",
- data: { term: $("#autocomplete_text").val()},
- dataType: "json",
- type: "POST",
- success: function(data){
- response(data);
- }
- });
- }
- });
- });
- </script>