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

Example of positioning #66

Closed
webcliq opened this issue Jul 31, 2012 · 2 comments
Closed

Example of positioning #66

webcliq opened this issue Jul 31, 2012 · 2 comments

Comments

@webcliq
Copy link

webcliq commented Jul 31, 2012

Sorry to be a nuisance. Can you provide practical example of positioning Context Menu, ideally bottom left of calling element.

@rodneyrehm
Copy link
Contributor

I assume you have jQuery UI position loaded:

$.contextMenu({
    selector: '.foobar',
    // …
    determinePosition: function($menu) {
        // .position() is provided as a jQuery UI utility
        // (...and it won't work on hidden elements)
        $menu.css('display', 'block').position({
            my: "right top",
            at: "left bottom",
            of: this,
            offset: "0 5",
            collision: "fit"
        }).css('display', 'none');
    }
});

@webcliq
Copy link
Author

webcliq commented Aug 1, 2012

Thankyou for your response.

I generate my Javascript / jQuery dynamically from a PHP Class. I had not been able to make contextMenu with positioning work without a syntax error. Having received your reply, I still received a syntax error but was then able to address the problem by escaping the $menu ($menu). However still no joy.

I have discovered that the if / else that tests whether ui.postion is loaded was testing false. My jQuery UI is 1.8.18 and I believe that it ui.position is loading as part of it. I use it for Tip positioning. Escaping the $menu may also have some effect but I cannot progress without making this adjustment.

I am able to achieve the result I desire in my specific project by adjusting the offset x and y on the fly but this is not entirely satisfactory. I am not certain that you can do anything about this but I thought I would like to say thanks and let you know in case someone else reports a similar problem.

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