0

I just created and developed a jQuery plugin and it is working fine. But when I call more than one instance of it, some functions will affect on another instance. For example, I have list of items and a "Delete" button before each item. When you click on each "Delete" item, following function will fire:

$('.del-item').each(function(){
        $(this).on('click',function(){
            var $e = $(this).parent();
            var val = $e.data('val');
            $sourceBox.find('.source-item[data-val='+val+']').removeClass('selected-item added').find('span').remove();
            $el.find('option[value='+val+']').removeAttr('selected').trigger('change');
            $el.trigger('change');
            $e.slideUp(200,function(){
                $e.remove();                
            });
        });
    });

But it removes items from another list or affect on another instance of plugin. Please advice how can I access to only related items?

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.