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

Use of class instead of id's for multiple toolbars on same page? #13

Open
macsupport opened this issue Feb 17, 2013 · 9 comments
Open

Comments

@macsupport
Copy link

Is there a method to load the toolbar using classes for both the link and for the content div? I have an image gallery with buttons for each image ( favorite, print, info, etc.) and I want to use a single icon to click to open the toolbar but be able to use classes so I don't have to have an id for each toolbar ( the page has many images on it).

@skyzyx
Copy link

skyzyx commented Mar 28, 2013

Using data attributes would be far better.

@macsupport
Copy link
Author

Ahh, much better!

@macsupport
Copy link
Author

Does this mean one can't do this? Not sure why it was closed without at least a comment.

@paulkinzett
Copy link
Owner

Hi

Sorry I thought this one was solved.

If you had HTML like below...

<div class="settings-button" data-toolbar="true"><img src="img/icon-cog-small.png" /></div>
<div class="settings-button" data-toolbar="true"><img src="img/icon-cog-small.png" /></div>
<div class="settings-button" data-toolbar="true"><img src="img/icon-cog-small.png" /></div>

Then you could load all the toolbars using the Js

$('div[data-toolbar]').toolbar({
    content: '#user-options',
    position: 'top'
});

Is that what you are after?

@paulkinzett paulkinzett reopened this Apr 5, 2013
@macsupport
Copy link
Author

Thanks. This works but the toolbar icons do not respond to a click. In this scenario, would I need a click handler for each icon?
I tried:

$('.toolbar-icons a').on('click', function() {
                    $(this).click();                     
                });

Gives me "too much recursion"

@bergmark
Copy link

bergmark commented Jun 4, 2013

@macsupport click triggers the click handlers, so that's why it recurses.

@qtronik
Copy link

qtronik commented Nov 28, 2013

this on "toolbarItemClick" function do not return the cliked ITEM object but the tool bar trigger itself...

@mvkamalesh
Copy link

Hi Paul,

$('div[data-toolbar]').toolbar({
content: '#user-options',
position: 'top'
});

above works well but i need the content: part also to be unique?

I have a listing page with 10 posts per page i want each post to have a toolbar, currently same content tools for all the post. how do i achieve this.

regards,
kamalesh mv

@ashffaq
Copy link

ashffaq commented May 18, 2015

@mvkamalesh

I figured it out by writing the init script in the loop, you have to define and different id for each post,

          <?php $counter = 1 ?>

           <div class="btn-toolbar" id="sharebutton<?php echo $counter; ?>"></div>
            <div id="toolbar-options<?php echo $counter; ?>"  class="hidden">

            </div>
            <script type="text/javascript">
            $('#sharebutton<?php echo $counter; ?>').toolbar({
                content: '#toolbar-options<?php echo $counter; ?>',
                position: 'top',
                animation: 'bounce',
                adjustment: 25,
            });
            </script>

           <?php $counter ++ ?>

$counter will increase every time loop run and will create different ids

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

7 participants