Skip to content Skip to sidebar Skip to footer

How To Loop On The List View (clientside To Disable Specific Check Box In)

I have a listview like this : )) { // reference to current widget wrappervar widget = $(this).parents(settings.widgetSelector); // disable and select (all) contained checkboxes widget.find('input[type=checkbox]').prop({disabled: true, checked: true});​​​​​​​​​​​​​​ // animate and remove widget... widget.animate({ opacity: 0 ...

Note that this solution will disable and select all contained checkboxes in a widget. If you have multiple checkboxes and only need to select a single one, give it a class (e.g. myCheckbox) and change the selector to

     widget.find('input[type=checkbox].myCheckbox').attr({disabled: true, checked: true});​​​​​​​​​​​​​​

You should not use the existing checkbox ID if you have more than one widget, as element IDs should be unique for the whole document.

UPDATE:

Turned out that I misunderstood the problem: the checkboxes to be disabled are not inside the mentioned widgets and the actual task is to

…disable the input type="checkbox" if the value of the input type ="hidden" that exist in the same is equal to the id of the li (widget).

(See discussion in comments.)

This could be a solution:

...
$(settings.widgetSelector, $(settings.columns)).each(function () {
    var widgetId = this.id; 
    var thisWidgetSettings = iNettuts.getWidgetSettings(widgetId);
    if (thisWidgetSettings.removable) {
        $('<a href="#" class="remove">CLOSE</a>').mousedown(function (e) {
            e.stopPropagation();    
        }).click(function () {
            if(confirm('This widget will be removed, ok?')) {
                // Disable checkboxes which have a sibling hidden input field with value equal to widgetId
                $(​'table tr input[type=hidden]').filter(function() {
                    return $(this).val()​​​​​ == widgetId;
                }).siblings('input[type=checkbox]').prop({disabled:true, checked: true});

                // animate and remove widget...
                $(this).parents(settings.widgetSelector).animate({
                    opacity: 0
                ...

Post a Comment for "How To Loop On The List View (clientside To Disable Specific Check Box In)"