How to use jQuery IsDirty with RadCombobox SelectedIndexChanged and LoadsOnDemand

5 posts, 1 answers
  1. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 25 Jun 2010 Link to this post

    We are using jQuery to identify if a form isDirty which works great except when there is a radComboBox that has a selectedIndexChanged and loadsOnDemand?  When the user types something in the  RadComboBox,  jQuery sees the form as Dirty and when the user clicks cancel from the confirmation popup there is an error.  

    Is there a way to exclude the radComBox for the isDirty?


    Is there a way to stop the RadComboBox from postingBack to the OnSelectedIndexChanged if the user selects cancel from the confirmation popup?

    Attached is the error and here are snippets of our code:

    <telerik:RadComboBox runat="server" ID="PermitRadComboBox" Height="190px" Width="250px" 
        EmptyMessage="Type a code or name" MarkFirstMatch="true" EnableLoadOnDemand="true" 
        HighlightTemplatedItems="true" OnClientItemsRequested="UpdateItemCountField" 
        OnDataBound="PermitRadComboBox_DataBound" OnItemDataBound="PermitRadComboBox_ItemDataBound" 
        OnItemsRequested="PermitRadComboBox_ItemsRequested" DropDownWidth="450px" AutoPostBack="True" 
        CausesValidation="False" OnSelectedIndexChanged="PermitRadComboBox_SelectedIndexChanged">  
                <li class="col1">Number</li> 
                <li class="col2">Permittee</li> 
                <li class="col1">  
                    <%# DataBinder.Eval(Container.DataItem, "permit_number") %></li>  
                <li class="col2">  
                    <%# DataBinder.Eval(Container.DataItem, "permittee") %></li>  
            A total of  
            <asp:Literal runat="server" ID="RadComboItemsCount" /> 

    <script type="text/javascript">  
        var isDirty = false;  
        var msg = 'This page has unsaved changes.\n\nClick OK to abandon the changes and leave the page.\n\nClick Cancel to stay on the page so you can save your changes.';  
        $(document).ready(function ()  
            $(':input').change(function ()  
                if (!isDirty)  
                    isDirty = true;  
            window.onbeforeunload = function ()  
                if (isDirty) return msg;  

    We are very new to the jQuery framework so any help very much appreciated.

    Thanks in advance,

  2. Answer
    Yana avatar
    4841 posts

    Posted 01 Jul 2010 Link to this post

    Hello Gene,

    You can exclude the combobox input by modifying your javascript function like this:

    $(document).ready(function() {
        $(':input').change(function() {
            if (this.className != "rcbInput") {
                if (!isDirty) {
                    isDirty = true;

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Phil
    Phil avatar
    5 posts
    Member since:
    Oct 2011

    Posted 12 Mar 2012 Link to this post

    This does not seems to work with IE.
  4. Ivana
    Ivana avatar
    657 posts

    Posted 15 Mar 2012 Link to this post

    Hi Phil,

    I have just tested this scenario and everything works as it should in IE and other browsers. Could you specify what exactly is not working at your end? You could also send us a sample illustrating the bad behavior.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Phil
    Phil avatar
    5 posts
    Member since:
    Oct 2011

    Posted 16 Jul 2012 Link to this post

    Never mind. I got it working. 
Back to Top