This is a migrated thread and some comments may be shown as answers.

Links opened using javascript?

3 Answers 148 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Micha
Top achievements
Rank 1
Micha asked on 27 Oct 2011, 07:01 AM
I'm using the menu widget in a jquery mobile application. 
JQuery mobile enhance all links, that theire content is loaded using an ajax request instead a normal post. 

Either this isn't working with the menu widget. Is the menu widget changing the url by javascript? How can I prevent this behaviour and enforce the widget that it uses the default browser behaviour or at least, to prevent kendo ui from handling the link and doing the forward myself?

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Oct 2011, 09:27 AM
Hi Micha,

The Kendo menu does not change URLs with Javascript, neither does it rely on Javascript in order to navigate. However, there is an e.stopPropagation() statement in the menu items' click handler. This will interfere with any click event listeners that be may attached to the document. I am not sure how jQuery Mobile works with regard to the discussed scenario, but you can try commenting out the following line and see whether it makes any difference:

kendo.menu.js

_click: function (e) {
            var that = this, openHandle;
            //e.stopPropagation();

            var element = $(e.currentTarget);

            if (element.hasClass(DISABLEDSTATE)) {
                e.preventDefault();
                return;
            }

            that.trigger(SELECT, { item: element[0] });

            if (!element.parent().hasClass(MENU) || (!that.options.openOnClick && !touch)) {
                return;
            }

            e.preventDefault();

            that.clicked = true;
            openHandle = element.children(".k-animation-container, .k-group").is(":visible") ? CLOSE : OPEN;

            that.trigger(openHandle, { item: element[0] });
            that[openHandle](element);
        }


The e.preventDefault() statement will prevent navigation if the item has child items and openOnClick is enabled.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
PPCnSEO
Top achievements
Rank 1
answered on 25 Nov 2011, 01:54 PM
I have an issue closely related to this which I managed to manually debug right down to that e.stopPropogation (before hitting the forums!)

My situation was that I had a kendo window popup using a jquery.live() attachment.
This worked perfectly except in the menu and was needed since some elements are added after dom load.
Using a .click() instead of live works in the menu but not with elements added after dom load(without running the .click every dom change).

Can I ask what the purpose of the stopPropogation is and whether the current usage is the best way?

After commenting that line I found no effect on functionality and got my script working in all situations.
I have found the solution, however I dislike using hacks which could break at any update if it is possible to get the fix upstream.

If the stopPropogation could be called only when entirely needed that could likely avoid these issues for Micha, myself and many more to come.
0
Dimo
Telerik team
answered on 29 Nov 2011, 08:52 AM
Hello Mark,

The purpose ot stopPropagation in this scenario is to prevent event bubbling the triggering of click (and select) events for parent Menu items of the clicked one. However, we found a way to address this and removed the problematic line.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Menu
Asked by
Micha
Top achievements
Rank 1
Answers by
Dimo
Telerik team
PPCnSEO
Top achievements
Rank 1
Share this question
or