Links opened using javascript?

4 posts, 0 answers
  1. Micha
    Micha avatar
    14 posts
    Member since:
    Oct 2011

    Posted 27 Oct 2011 Link to this post

    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?
  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 28 Oct 2011 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. PPCnSEO
    PPCnSEO avatar
    16 posts
    Member since:
    Nov 2011

    Posted 25 Nov 2011 Link to this post

    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.
  5. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 29 Nov 2011 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready