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

JQuery in EditForm UserControl conflict

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nancy
Top achievements
Rank 1
Nancy asked on 07 Feb 2014, 04:54 AM
I am using a RadGrid with a user control - on the control are Update/Cancel buttons. I added some jquery to enable them when a user changes something. I've noticed though that it only works on the topmost row in the grid. Can someone help me get the jquery correct to enable the buttons on the correct row. Currently the btnUpdate.ClientID is not grabbing the correct row update button - I assume I need to be passing the event somehow - the clientIDs change by row - for example the srcElement.id of the textbox is "ctl00_ContentPlaceHolder1_ctrlReviews_rgReview_ctl00_ctl05_EditFormControl_txtVendorEngagementID" but the textBoxChanged button found is
ctl00_ContentPlaceHolder1_ctrlReviews_rgReview_ctl00_ctl07_EditFormControl_btnUpdate. It should be ct105.


<script type="text/javascript">
var ischanged = false;

$(document).ready(function () {
$('input').keydown(function (event) {
if (event.srcElement.id.indexOf("ctrlReviews_rgReview") != -1) {
textBoxChanged();
}
});
$('select').keydown(function (event) {
if (event.srcElement.id.indexOf("ctrlReviews_rgReview") != -1) {
textBoxChanged();
}
});
$('textarea').keydown(function (event) {
if (event.srcElement.id.indexOf("ctrlReviews_rgReview") != -1) {
textBoxChanged();
}
});
function textBoxChanged() {
$('#hdnIsChanged').value = "true";
var btn = $('#trButtons').find("#<%=btnUpdate.ClientID%>");
btn.removeAttr("disabled");
}
});

</script>

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 11 Feb 2014, 09:38 AM
Hi,

Another option to find the correct update button is to use the *= contains selector in jQuery and simply look for the "btnUpdate" string in the common HTML parent element of the textbox and the button - which can be for example the HTML table of the edit form of the grid. Then the code can look something like this;
$(editForm).find("[id*='btnUpdate' "]); which will return only the update button in the current edit form of the textbox.

Regards,
Marin
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Nancy
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or