Disabling anchor tag button

2 posts, 0 answers
  1. Russ
    Russ avatar
    10 posts
    Member since:
    May 2012

    Posted 21 Oct 2013 Link to this post

    I have a view that has a navigation button to another view that looks like this:
    <a id="GoIssue" data-role="button" href="Main/Issue?priorPage=Picklist&fieldName=reqOrWO&value={TBS}" data-icon="details" ></a><br>

    I'd like to disable it under certain conditions.   I have tried adding a class to it and checking the class in the click handler:
    //  Start disabled until someone puts something IN the reqOrWO field
    $('#GoIssue').addClass("disabled");
     
    //  disabled is implemented by returning false on the click action if it has the disabled class
    //  the disabled class also has visual aspects as well.
    $('#GoIssue').click(function ()
        {
            event.preventDefault ? event.preventDefault() : event.returnValue = false;
            return (!$(this).hasClass('disabled'));
        });
    At first, I just tried returning false, but navigation still occurred.  So, I tried adding the additional code to call preventDefault() [if present] and event.returnValue [if not].  But none of this seems to prevent the navigation from going to the target page.

    Am I missing something?  Is there a simpler way?

    Thanks

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2598 posts

    Posted 23 Oct 2013 Link to this post

    Hello Russell,

    Unfortunately enable/disable functionality of the Kendo UI Mobile Button is not supported at the moment. But please take a look at the following blog post, discussing a similar problem and a possible resolution:

    http://www.kendoui.com/forums/kendo-ui-mobile/button/enable-disable-kendo-ui-mobile-button.aspx

    If you want to prevent the clicking of the button, you can use the data-click attribute and handle the event parameter there (e.preventDefault).
     
    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top