$(function() { $("#tags").autocomplete({ source: "/Home/TakeGry", minLength:"> $(function() { $("#tags").autocomplete({ source: "/Home/TakeGry", minLength:"> $(function() { $("#tags").autocomplete({ source: "/Home/TakeGry", minLength:" />

JQuery avtomatik yakunini ishlatib, Enter ni tanlang RadioButton ni tanlang

Men asp.netda dastur yozyapman, MVC 3 modelini ishlataman. jQuery autocomplete-da mos nomni izlab, keyin Enter ni bosib, uni qanday amalga oshirish kerakligini bilmayman, dastur RadioButton-ni tekshiradi.

<script type="text/javascript">
    $(function() {                       
        $("#tags").autocomplete({
            source: "/Home/TakeGry",
            minLength: 1,
            select: function (event, ui) {
           //I suspect that something needs to add here  
            }
        });
    });
</script>

<table>
    <tr>
        <th>
            <div class="demo">
                <div class="ui-widget">
                    
                    <input id="tags" />
                    <input id="hiddenElementID" type="hidden" />
                </div>
            </div>
        </th>
        <th>

        </th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Nazwa)
        </td>
        <td>
           //One of these RadioButton's should be checked, when I hit enter
            @Html.RadioButtonFor(modelItem => item.GraID, new { id = item.GraID })
        </td>
    </tr>
}
1

2 javoblar

funktsiya faqat satrlarni to'plashni talab qiladi. bo'sh joyni ajratuvchi mag'lubiyatga ega bo'lgan va so'ngra bo'shliqda bir qatorga bo'linib, funksiyaga o'tkazadigan qo'lda chop qilishingiz mumkin:

$(function() {
    var list;
    $.post("/Home/TakeGry", { }, function(result) {
        list = result.split(' ');
    });


    $("#tags").autocomplete(list);
});
0
qo'shib qo'ydi
OK, men sizni ushbu hodisadan foydalangan holda qilishingiz kerak, deb o'ylayman: Bog'lanish
qo'shib qo'ydi muallif Mats Edvinsson, manba
Mening jQuery autocomplee funktsiyasi juda yaxshi ishlaydi, lekin avto-to'ldirish ro'yxatidan biror narsa tanlaganimda, RadioButton avtomatik ravishda tanlangan bo'lishi lozim. Sahifani qayta yuklamasdan qanday qilib asinxronlik qilishni bilmayman.
qo'shib qo'ydi muallif tzm, manba

Bir necha soatdan so'ng, men quyidagi javobni topdim:

Buyruqlarimni o'zgartirishim kerak:

<script type="text/javascript">
$(function() {
    $("#tags").autocomplete({
        source: "/Home/TakeGry",
        minLength: 0,
        select: function (event, ui) {
            if (ui.item) {
                $('input[name="' +ui.item.value+ '"]').attr('checked', true);                    
            }
        }
    });
});

Va foreach (qaysi bosim nomlari va RadioButtons) i buni o'zgartirish kerak:

@Html.RadioButtonFor(modelItem => item.GraID, new { id = item.GraID })

Kimga:

<input type="radio" name='@item.Nazwa' id="radioButton" value="{ id = @item.GraID }" />

Har qanday yordam uchun minnatdormiz :).

0
qo'shib qo'ydi
Javascript UZB
Javascript UZB
99 ishtirokchilar

@js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb