simonexmachina / jquery-bonsai

Super lightweight jQuery tree plugin
http://simonwade.me/jquery-bonsai
MIT License
148 stars 42 forks source link

Dynamic Content and refreshing #8

Closed alex-martin-xactium closed 9 years ago

alex-martin-xactium commented 9 years ago

Hi,

I have a dynamically generated list, that utilises javascript remoting. Unfortunately, this runs Asynchronously and results in the styling being applied before the data has finished generating. If i try apply the styling from bonsai after every call or any change, it only works once, then doesn't do anything.

Any way around this? I'd like to be able to keep adding data to the tree and apply the styling to the new data.

simonexmachina commented 9 years ago

Bonsai definitely does deal with that use case. Can you post an example in jsbin?

alex-martin-xactium commented 9 years ago

JSBin is a bit difficult, as I use visualforce to generate the content. But I generate a tree and apply the following JS code. Tree looks fine. When i expand the tree, by adding more ol and li items, i try to re-apply the following code using the JS console. It doesn't do anything, just remains as half a stylised tree.

If that's not clear, i can do a short clip demoing the issue.

        $j('#list1').bonsai({
            expandAll: true,
            checkboxes: true, // depends on jquery.qubit plugin
            createCheckboxes: true,
            handleDuplicateCheckboxes: true
        });                     
alex-martin-xactium commented 9 years ago

Found the solution. Calling .bonsai('update'); works.

Thanks,

simonexmachina commented 9 years ago

That's the ticket! Was that info on the readme or website?

On Sat, 29 Nov 2014 01:20 Alex Martin notifications@github.com wrote:

Found the solution. Calling .bonsai('update'); works.

Thanks,

— Reply to this email directly or view it on GitHub https://github.com/aexmachina/jquery-bonsai/issues/8#issuecomment-64898460 .