0

I duplicate values checkpoint to another block. By clicking on the new element, it must be removed and the filter selection, too. Please help find the mistake.

    $('.views-exposed-widget').on('change', 'input', function () {
        var self = $(this),
            name = this.name,
            text = self.closest('.form-type-radio').find('label[class="option"]').text(),
            target = $('.duplicate-filter').find('[data-for="'+ name +'"]');

        if (target.length == 0){
            target = $('<span class="o_filt" data-for="'+name+'"></span>').appendTo('.duplicate-filter');
        }
        target.text( text );

        $('.o_filt').on('click', function(){
            var l = $(this).text();
                m = $('.views-exposed-form .form-type-radio label.option');
            $(this).remove();
            m.each(function(){
                if($(this).text().indexOf(l)!=-1){
                    $(this).closest('input[type="radio"].dls-radio').removeAttr('checked');                     
                }
            });
        });

    }); 

Example: http://jsfiddle.net/e59ogp8a/5/

unknown163
  • 57
  • 7
  • in the same way you are using `name` in `data-for` to replace the current selection, you should be able to use it to uncheck the relevant radio buttons. Same as your last question but going the other way... – Rhumborl Nov 19 '14 at 16:08
  • I don't see any checkboxes... – Tomanow Nov 19 '14 at 16:12
  • @Tomanow its stylized. Need to remove attribute from input[type="radio"].dls-radio – unknown163 Nov 19 '14 at 16:16
  • possible duplicate of [How to uncheck a radio button?](http://stackoverflow.com/questions/2117538/how-to-uncheck-a-radio-button) – leftiness Nov 19 '14 at 16:30

1 Answers1

1

Use .prop('checked', false) like so:

        $('.o_filt').on('click', function () {
            var l = $(this).text();
            $(this).remove();
            $('input[name="' + $(this).data('for') + '"]').prop('checked', false);
        });

FIDDLE

Tomanow
  • 7,247
  • 3
  • 24
  • 52