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

List is generated dynamically #37

Closed
kidino opened this issue May 15, 2017 · 6 comments
Closed

List is generated dynamically #37

kidino opened this issue May 15, 2017 · 6 comments

Comments

@kidino
Copy link

kidino commented May 15, 2017

I have an ajax process where I download the hierarchy and the items first. Then I populate my list dynamically. But the collapse and expand doesn't seem to work.

@camohub
Copy link
Owner

camohub commented May 15, 2017

What do you populate dynamically? I don't understand why? List has been changed. Its state is actual. Also which part of expanding/collapsing does not work? Opener buttons or automatic expanding while dragging?

@camohub
Copy link
Owner

camohub commented May 15, 2017

Did you try to initialize the populated list again after ajax request?

@kidino
Copy link
Author

kidino commented May 16, 2017

Yes I did. The reason I am doing this is because my data may contain over 400 nodes. I don't want the page to take a long time to load, so I thought of loading the page and then load the data using Ajax. I am loading the data using 2 Ajax call, where one loads up the hierarchy, and the other loads up the item information.

My code is more or less like this.

<script>
var odata;
var ohierarchy;
$(document).ready(function(){
		var a1 = $.ajax({
			url : base_url + 'aj_get_data',
			dataType: 'text',
			method : 'post'
		});
		
		var a2 = $.ajax({
			url : base_url + 'aj_get_hierarchy',
			dataType: 'text',
			method : 'post'
		});
		
		$.when(a1, a2).done(function(d1, d2){
			odata = JSON.parse(d1[0]);
			ohierarchy = JSON.parse(d2[0]);
			console.log( odata );
			console.log( ohierarchy );
			
			var ohtml = $.Deferred();
			var obj = {};
			
			ohtml.promise(obj);
			ohtml.resolve( build_hierarchy(ohierarchy) );
			// build_hierarchy() is a recursive function to generate ul-li HTML
			
			obj.done(function(html){				
				console.log(html);
				$('#sortable-list').html( html );			
				var options = {
					ignoreClass: 'clickable',
					hintClass: 'hintClass',
					placeholderClass: 'placeholderClass',
				};
				$('#sortable-list').sortableLists(options);				
			});
			
		});	
});	
</script>

The sortable list is working & I can drag things around but

  • it does not generate the caret icon for expand and collapsing items with children
  • I cannot click on my custom buttons, the one that I the 'clickable' class.

@camohub
Copy link
Owner

camohub commented May 16, 2017

Ok I understand. It is little weird if everithing works but open/close buttons not. For sure, do you have opener section in options object?

@kidino
Copy link
Author

kidino commented May 16, 2017

Oh man, I missed that. It is working now.

Previously I see that the span was generated on object drop. I just used CSS to style the span.

@camohub
Copy link
Owner

camohub commented May 16, 2017

Ok.

@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

2 participants