This is a migrated thread and some comments may be shown as answers.
How to use jQuery IsDirty with RadCombobox SelectedIndexChanged and LoadsOnDemand
4 Answers 76 Views
This is a migrated thread and some comments may be shown as answers.
Gene
Top achievements
Rank 1
Gene asked on 25 Jun 2010, 09:09 PM
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?

OR

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">  
    <HeaderTemplate> 
        <ul> 
            <li class="col1">Number</li> 
            <li class="col2">Permittee</li> 
        </ul> 
    </HeaderTemplate> 
    <ItemTemplate> 
        <ul> 
            <li class="col1">  
                <%# DataBinder.Eval(Container.DataItem, "permit_number") %></li>  
            <li class="col2">  
                <%# DataBinder.Eval(Container.DataItem, "permittee") %></li>  
        </ul> 
    </ItemTemplate> 
    <FooterTemplate> 
        A total of  
        <asp:Literal runat="server" ID="RadComboItemsCount" /> 
        items  
    </FooterTemplate> 
</telerik:RadComboBox> 


<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;  
        };  
    });  
 
</script> 


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

Thanks in advance,
Gene.


4 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 01 Jul 2010, 11:45 AM
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,
Yana
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
0
Phil
Top achievements
Rank 1
answered on 12 Mar 2012, 05:25 PM
This does not seems to work with IE.
0
Ivana
Telerik team
answered on 15 Mar 2012, 03:24 PM
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,
Ivana
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.
0
Phil
Top achievements
Rank 1
answered on 16 Jul 2012, 04:08 PM
Never mind. I got it working. 
Asked by
Gene
Top achievements
Rank 1
Answers by
Yana
Telerik team
Phil
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or