samedi 1 juillet 2017

How to get the particular checked checkboxes, generated dynamically in jquery

I have div in which i append dynamic widgets that each contains a checkbox at the toolbar. This checkbox is use to control the widget, therefore i have set a serial numbers which are dynamically set as ids. Each one is unique so i think they are good for ids.

The problem now is how can i retrieve the exact id of the checked checkbox. This returns the id of the last checkbox in the div as it loop uncontrollably.

I have a spinet bellow:

                    for (var i=0; i < sortedIds.length; i++) {

                            $("#batch_schedule_wraper").append("<div class='col-xs-12  col-sm-6 widget-container-col'>"
                                   +"<div class='widget-box widget-color-blue'>"
                                            +"<div class='widget-header'>"
                                                  +"<h5 class='widget-title bigger lighter'>"+sortedIds[i]+"</h5>"
                                                    +"<div class='widget-toolbar'>"
                                                                 +"<div class='ontrol-group'>"
                                                                         +"<div class='checkbox'>"
                                                                                +"<label class='block'>"
                                                                                        +"<input name='form-field-checkbox' type='checkbox' class='ace input-lg remove_widget' id=''/>"
                                                                                        +"<span class='lbl bigger-120'>Batch</span>"
                                                                               +" </label>"
                                                                        +"</div>"                                                                                          
                                                                    +"</div>"
                                                            +"</div>"
                                            +"</div>"
                                            +"<div class='widget-body'>"
                                                    +"<div class='widget-main'>"
                                                        +"<div class='test_list_wraper'></div>"
                                                    +"</div>"
                                            +"</div>"
                                    +"</div>"                               
                            +"</div>");                                                         $("[name='form-field-checkbox']").attr("id",sortedIds[i]);

                    }




Aucun commentaire:

Enregistrer un commentaire