![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 99 Pomógł: 5 Dołączył: 18.03.2015 Ostrzeżenie: (0%) ![]() ![]() |
Próbuje wdrożyć ten autocomplete: http://www.bewebdeveloper.com/tutorial-abo...ysql-and-jquery i działa ładnie z tym że posiadam naście identycznych inputów a autocomplete pojawia się tylko dla pierwszego.
Mój input wygląda tak: a kolejne inputy pojawiają się przy użyciu funkcji clone(), natomiast kod js prezentuje się tak:
więc jest minimalnie inny od tego z przykładu ponieważ w przykładzie opierał się na ID. Wiem że muszę dla każdego inputa nadać inne ID i dostosować do tego kod js tylko nie mam zielonego pojęcia jak, od czego zacząć? |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 99 Pomógł: 5 Dołączył: 18.03.2015 Ostrzeżenie: (0%) ![]() ![]() |
Znowu nie rozumiem o co chodzi i tu chyba mam największy problem
![]() EDIT. Ponieważ w js mam już podobna działającą funkcję datepickera próbowałem na podobnej zasadzie dopisać obsługę autocomplete, niestety rezultat nie przyniósł chcianych efektów. W chwili obecnej to mam:
Na próbę jak zrobię tak: Kod <li> <input type="text" class="ingredient" name="ingredient[]" onkeyup="autocomplet()" autocomplete="off" value="" /> <ul id="ingredient_list_id"></ul> <input type="text" class="datepicker" name="deliverydate[]" autocomplete="off" value="" /> </li> <li> <input type="text" class="ingredient" name="ingredient[]" onkeyup="autocomplet2()" autocomplete="off" value="" /> <ul id="ingredient_list_id"></ul> <input type="text" class="datepicker" name="deliverydate[]" autocomplete="off" value="" /> </li> i Kod $('button').on('click', function(event) { event.preventDefault(); var lines = $('#lines'); var i = 0; $('input.datepicker').datepicker("destroy"); lines.append(lines.find('li:first-child').clone()); $('.datepicker').each(function () { $(this).attr("id",'datepicker' + i).datepicker(); i++; }); }); $('input.datepicker').datepicker(); $( function() { $( "#datepicker" ).datepicker(); } ); // autocomplet : this function will be executed every time we change the text function autocomplet() { var min_length = 1; // min caracters to display the autocomplete var keyword = $('.ingredient').val(); if (keyword.length >= min_length) { $.ajax({ url: 'ajax_refresh.php', type: 'POST', data: {keyword:keyword}, success:function(data){ $('#ingredient_list_id').show(); $('#ingredient_list_id').html(data); } }); } else { $('#ingredient_list_id').hide(); } } function autocomplet2() { var min_length = 1; // min caracters to display the autocomplete var keyword = $('.ingredient').val(); if (keyword.length >= min_length) { $.ajax({ url: 'ajax_refresh.php', type: 'POST', data: {keyword:keyword}, success:function(data){ $('#ingredient_list_id').show(); $('#ingredient_list_id').html(data); } }); } else { $('#ingredient_list_id').hide(); } } // set_item : this function will be executed when we select an item function set_item(item) { // change input value $('.ingredient').val(item); // hide proposition list $('#ingredient_list_id').hide(); } Drugi input nie działa, tzn. nie ma podpowiedzi w ogóle, pierwszy input działa normalnie z tym że wybrana opcja pojawia się w wszystkich inputach. Ten post edytował lustfingers 31.03.2017, 18:08:27 |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 14.08.2025 - 20:19 |