Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i add remove button for li element as open/close button? #32

Closed
pyaehein opened this issue Nov 10, 2016 · 7 comments
Closed

How can i add remove button for li element as open/close button? #32

pyaehein opened this issue Nov 10, 2016 · 7 comments

Comments

@pyaehein
Copy link

I want to use add and remove li list. I can add easily with jquery but i don't know how to add delete button as open/close like button. How can i do it ?

@camohub
Copy link
Owner

camohub commented Nov 15, 2016

<li><div><i class="fa fa-trash ignore-class"></i>item xy</div></li>

$('.fa-trash').on('click', function()
{
    $(this).closest('li').remove();
});

I did not test it. Of course you have to check if the ul warapper of removed li remains empty.

@kidino
Copy link

kidino commented May 15, 2017

I think in my implementation, it is also ignoring the ignore-class .... I cannot click on it

@kidino
Copy link

kidino commented May 15, 2017

By the way, here is how I remove a node, and move the content upwards. So you only delete that one item and not the children.

function ontology_remove(item_id){
	var parent = $('#'+item_id).parent();
	var children = $('#'+item_id).find('ul').html();
	parent.prepend(children);
	$('#'+item_id).fadeOut().remove();
}

@camohub
Copy link
Owner

camohub commented May 15, 2017

What it means "also ignoring the ignore-class". I dont know the structure of your list. Can you create an example and be little clear in explanation?

@kidino
Copy link

kidino commented May 16, 2017

What I mean is this ... here is my options

					var options = {
						ignoreClass: 'clickable',
						hintClass: 'hintClass',
						placeholderClass: 'placeholderClass',
					}

And here is my HTML

			<li id="item_1"><div>One 
				<a class="clickable btn-onto btn btn-xs btn-danger pull-right"><i class="fa fa-times"></i></a>
				<a class="clickable btn-onto btn btn-xs btn-primary pull-right"><i class="fa fa-pencil"></i></a>				
			</div></li>

See, I have the 'clickable' class. But I cannot click on the button. When clicking on it, it behave like I want to drag the whole item.

@camohub
Copy link
Owner

camohub commented May 16, 2017

The reason is, the <i> element has to have clickable class too. Every element in "clickable" tree has to have clickable class.

@kidino
Copy link

kidino commented May 16, 2017

All good. Thanks!

@camohub camohub closed this as completed May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants