Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:53:05+00:00 2026-06-11T20:53:05+00:00

I’m rather new to web development so I’m using MVC with ASP.NET and I’ve

  • 0

I’m rather new to web development so I’m using MVC with ASP.NET and I’ve got an hard time with jQuery and its functions. I’m using the Razor View Engine with ASP.NET MVC c# with devexpress controls if that helps.

Now this is my problem:

I got a View which has an @Html.Action(‘view’,’controller’); declared which links to a gridview.

On that gridview I got some clientside functions that presents a detail View when a row is selected and Enter is pressed on the keyboard.

Now the gridview I’m using has some automated search options by clicking in a textfield and typing in what you want to look for and press enter.
I declared a value which holds a value if I’m searching or selecting a row and press enter.

So after that I got it to work that when I press enter in the search textfield it wont open the Detail View. But it performs a callback when searching. In which the gridview is newly created. Now I got the problem that my function doesn’t find the element anymore after this callback on the GridView.

I tried using the .find function in jquery but that didn’t help. Here are some snippets I tried:

(these are located in a $(document).ready function)

 $('#id').click(function () {
    // do something
 });

And the .find version:

 $('#gridview').find('#id').click(function () {
    // do  something
});

So basically I want to be able to find the element AFTER the gridview has been build again.

::EDIT::
The ID’s on the textfields.click stay the same.

::EDIT2::
I’ve found a cheap and dirty solution by adding my current code inside the EndCallback clientsideevent of the devexpress gridview. But there must be a decent way to do this…
But this also proves my previous edit, where the id’s stay the same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:53:06+00:00Added an answer on June 11, 2026 at 8:53 pm

    When you call a function that binds event handlers, such as .click(), on a jQuery object containing a set of elements, the event handler is bound to only those elements; it won’t also apply to any elements that are subsequently created that match the selector. If you replace those elements, even if the new element has the same id, the event handler disappears along with it. There is a solution for this, however, and it’s called event delegation.

    The basic principle is that you bind an event handler to an element that won’t be replaced, which will contain all of your elements that you want to trigger the event, and pass it an event type, a selector to match the elements to trigger the function for that event type, and a function to execute. In jQuery 1.7 or later, this is achieved using one of the variations of the .on() function:

    $('#gridview').on('click', '#id', function(e) {
        // do something when the element with an id of 'id' is clicked on
    });
    

    Note that I’ve assumed your #gridview element is never replaced. If it is, choose another element that you can reference that contains the #gridview element. If all else fails, you can call it on the document itself.

    For more information, take a look at the Direct and delegated events section in the jQuery documentation for .on().

    If you’re still using a version of jQuery prior to 1.7, you’ll need to use the .delegate() function instead. It works in the same way, but the first two arguments (the event type and selector) are switched around:

    $('#gridview').delegate('#id', 'click', function(e) {
        // do something when the element with an id of 'id' is clicked on
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.