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

attach toolbar to element after ajax div reload #55

Open
OttoVanzig opened this issue Nov 4, 2016 · 1 comment
Open

attach toolbar to element after ajax div reload #55

OttoVanzig opened this issue Nov 4, 2016 · 1 comment

Comments

@OttoVanzig
Copy link

hi there,
I'm using multiple js toolbar on files icon and it works fine.
I wonder how to attach the toolbar to a new file icon after an ajax upload.
I tried to put an init() function with the toolbars remove (to suppress the old ones) and creation and call the init() in the upload/done event.
It looks like the new tool-containers are created but they are not displayed on click.
any idea
thanks in advance

@OttoVanzig
Copy link
Author

OttoVanzig commented Nov 7, 2016

hello again,
well I've been able to solve "half" on the problem.
What I did :
In the .js file a init() (outside the document.ready function) as below
` $('.tool-container').remove(); //remove all

    $('div[data-toolbar="file-ctrt-options"]').toolbar({
        content: '#toolbar-options',
        event: 'click',
        hideOnClick: true,
    }); //attach the toolbars

    //handle click event
    $(' .btn-toolbar').on('click', function(event) {
            //handle item click event
    $('div[data-toolbar="file-ctrt-options"]').on('toolbarItemClick', function(event, buttonClicked) {`

in the php file
<div id="toolbar-options" class="hidden">//the buttons</div>
And now to launch everything
in the .js file inside the document.ready function
init()
this works fine. All the different toolbars are working
When a file is oploaded :
ajax (done: load (files div) setTimeout(function() { //delete and recreate JS toolbar initJSToolbar(); }, 300);
this works ok for the files inside the reloaded div.
The only issue is that after this the others files on the page lost their toolbar !
they are effectively recreated but when you click on a file they are not fired, but they exists and it looks like they are linked to the right file.
Many thanks if somebody could have a advice !

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

1 participant