views:

90

answers:

2

Hi Guys, I am Not Familiar with JavaScript and i am beginner in Jqyery!
I Found RadMenu Pluging from web and want to use it to show my links as a Radial Menu. it is OK but I have a Simple Problem With it.
I want to khnow How Can I "Load"(better to say "Show") Radial Menu at the Page Load?!
I can Show or Hide the plugin with this codes:

<a href="#" onclick='jQuery("#radial_container").radmenu("show")'>Show Menu </a>
<a href="#" onclick='jQuery("#radial_container").radmenu("hide")'>Hide Menu </a>

with this way user should click the anchor tag to view the Menu. I want to show it at the page Load. How can I Handle that?

Here is the JQuery and Plugin Options that I used:

$(function() {
            jQuery("#radial_container").radmenu({
                listClass: 'list',
                itemClass: 'item',
                radius: 100,
                animSpeed: 400,
                centerX: 30,
                centerY: 100,
                selectEvent: "click",
                onSelect: function($selected) {
                    alert("you clicked on .. "
                    + $selected.index());
                },
                angleOffset: Math.PI,
                onShow: function($menuitems) {
                    $menuitems.each(function(i) {
                        var $this = jQuery(this);
                        setTimeout(function() {
                            $this.fadeIn(500);
                        }, i * 100);
                    });
                }
            });
        });
+1  A: 
addEventListener('load',
    function(){
        jQuery("#radial_container").radmenu("show");
    },
false);

If you wish to support IE too, use this instead:

addEventListener = window.addEventListener || window.attachEvent;
addEventListener('load',
    function() {
        jQuery("#radial_container").radmenu("show");
    },
false);
Delan Azabani
thank you but where should i place your code?! I placed it before above code(radMenu Initialization) and there was an error (Error: Object expected). if i use your code after above code there is no error but your event not working and the menu no showing.
mahdiahmadirad
This should be put after your code. It works just fine for me. What browser and version are you using?
Delan Azabani
i tested your code with chrome and it is ok, but it no working with IE8.
mahdiahmadirad
I have edited my answer. Try the second code sample and see if it works with IE.
Delan Azabani
unfortunatlly it is not working with IE. the Error message is clear: 'addEventListener' is undefined.
mahdiahmadirad
I have made a small mistake in the code. I've edited it to correct the problem; please try it again.
Delan Azabani
A: 

since you're calling the initialization within document.ready ($(function(){})), all you have to do after instantiating it is call .radmenu("show")

essentially you will have:

$(function() {
    jQuery("#radial_container").radmenu({
            listClass: 'list',
            itemClass: 'item',
            radius: 100,
            animSpeed: 400,
            centerX: 30,
            centerY: 100,
            selectEvent: "click",
            onSelect: function($selected) {
                alert("you clicked on .. "
                + $selected.index());
            },
            angleOffset: Math.PI,
            onShow: function($menuitems) {
                $menuitems.each(function(i) {
                    var $this = jQuery(this);
                    setTimeout(function() {
                        $this.fadeIn(500);
                    }, i * 100);
                });
            }
    }).radmenu("show");
});
Nirvana Tikku