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

Dropdown menu in context "user-login" #185

Closed
Watashifr opened this issue Mar 25, 2013 · 18 comments
Closed

Dropdown menu in context "user-login" #185

Watashifr opened this issue Mar 25, 2013 · 18 comments

Comments

@Watashifr
Copy link

Please consider the following code:

<div class="page-header bg-color-white" style="z-index:1000">
    <div class="page-header-content ">
        <h1>Title</h1>
        <ul class="menu">
            <li data-role="dropdown">
                <a href="#">
                    <div class="user-login">
                        <div class="name">
                            <span class="first-name">First</span>
                            <span class="last-name">Last</span>
                        </div>
                        <div class="avatar">
                            <img src="/usr/watashi/avatar100.png" />
                        </div>
                    </div>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="#">Logoff</a></li>
                </ul>
            </li>
        </ul>
    </div>
</div>

The idea is a context menu that appears when the avatar/username is clicked, but this concept seems to not work. Any thoughts?

@JohnArcher
Copy link
Contributor

Seems you forgot to include dropdown.js:

<script type="text/javascript" src="js/modern/dropdown.js"></script>

Nevertheless, the dropdown box does not appear under the user area on the right, but instead on the left (see screenshot). :-( Any chance to align that properly?
screenshot_49

@Watashifr
Copy link
Author

the dropdown script is included on the page (I only pasted part of the html). I can align the menu in the proper place by placing the <ul class="dropdown-menu"> inside the <a> tag, but I'm following the example found on the metroui website. When I set the ul to "dropdown-menu open" it will display in the correct place, but it will never close (or open). Another thing: my page shows a bullet point at the top left corner, belonging to the <li data-role="dropdown">.

@JohnArcher
Copy link
Contributor

So, the dropdown menu works for you? Then, what was your initial problem?

@Watashifr
Copy link
Author

check http://10ti.me/screenshot.png

@Watashifr
Copy link
Author

it doesn't. With "dropdown-menu open" it displays (but does not close), without "open" it does not show at all.

@JohnArcher
Copy link
Contributor

Hm, the link does not seem to work (for me).

At least, I also recognized the bullet point at top left on my site, too ...

@Watashifr
Copy link
Author

screenshot link fixed (sorry).

@JohnArcher
Copy link
Contributor

Hm, ok, I see. Well, I hope @olton has an idea, as I also need that functionality. :-)

@Watashifr
Copy link
Author

So yeah, this sort of turned into a feature request I guess: dropdown menus from "any given" (clickable) object.

@JohnArcher
Copy link
Contributor

+1

@icardo
Copy link

icardo commented Mar 27, 2013

I believe I did this earlier this week..

<div data-role="dropdown">

    <div class="tile icon">
    <div class="tile-content">
        <span class="icon-user"></span>
    </div>
</div>

    <ul class="dropdown-menu">
        <li><a href="/logout">Logout</a></li>
    </ul>

</div>

<div>
Ricardo Assing<span>Admin</span>
</div>

Untitled-2

Clicking on the red colored tile shows the menu.

Of course you need a bit of CSS.

ul.dropdown-menu {
position:absolute;
right:10px;
}

The CSS shown is just for the dropdown.

@icardo
Copy link

icardo commented Mar 27, 2013

I also had an issue with dropdown.js where if I added event handlers to my dropdown menu items, they weren't being triggered. I have a fix for this and made a pull request.

@Watashifr
Copy link
Author

trying to recreate your solution, but to no avail. class="dropdown-menu open" shows the menu renders in the right place, but it does not appear when the icon is clicked. Code below

@Watashifr
Copy link
Author

<div class="page-header bg-color-white" style="z-index:1000">
    <div class="page-header-content ">
        <h1>Title</h1>
        <div data-role="dropdown">
        <div class="user-login">
                <div class="name">
                    <span class="first-name">First</span>
                    <span class="last-name">Last</span>
                </div>
                <div class="avatar">
                    <img src="/usr/watashi/avatar100.png" />
                </div>
        </div>
        <ul class="dropdown-menu open">
            <li><a href="#">Logoff</a></li>
            <li><a href="/me">Me</a></li>
        </ul>                    
        </div>
    </div>
</div>

@icardo
Copy link

icardo commented Mar 28, 2013

I copied your markup and tested. It didn't work. Made some adjustments, try this which DID work:

<div data-role="dropdown" id="auth-menu">
    <div class="user-login">
            <div class="name">
                <span class="first-name">First</span>
                <span class="last-name">Last</span>
            </div>
            <div class="avatar">
                <img src="/usr/watashi/avatar100.png" />
            </div>
    </div>
<ul class="dropdown-menu">
        <li><a href="#">Logoff</a></li>
        <li><a href="/me">Me</a></li>
    </ul>             
</div>

CSS:
#auth-menu {
float:right;
position:relative;
}
#auth-menu > ul.dropdown-menu {
position:absolute;
right:10px;
}

Of course you can play around with the CSS to position wherever you want.

@Watashifr
Copy link
Author

Sorry, was away over easter. Tested today and no luck. When I set

    it displays correctly, but it seems I'm missing a trigger for the menu to open (and I can't figure out what that trigger should be).

@Watashifr
Copy link
Author

Ho hum. Forgot to include jquery. Excuse me whilst I crawl under a rock and shoot myself.

@JohnArcher
Copy link
Contributor

Thanks a lot, @icardo ! Works perfectly!

Nevertheless, I think it would be great if @olton would incorporate that as a built in function/control type, as I don't want to fiddle with that custom css in my project. Any chance? Спасибо! :-)

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