Retrieving the sender in JQuery autocomplete

I am using Jquery Autocomplete in my MVC3 application and I have multiple textboxes that I want to set up smartly. I am trying to return the autocomplete field property to the controller like this:

<script type="text/javascript" >
$(document).ready(function () {
    $(".AutoC[id]").autocomplete('@Url.Action("Liczba_wejsc", "Home")', { minChars: 1, selectFirst: true, extraParams: { "ID": $(this).attr('id')} });
});
</script> 
     <div class="editor-field">
 @Html.ValidationMessageFor(m => m.some_prop)
 <br/>@Html.TextBoxFor(m => m.some_prop, new {
 id = "some_id", @class = "AutoC" })
    </div>

However, I always end up receiving null as a result.

Answer №1

Alright, now I understand:


     </style>
 <script type="text/javascript" >
    $(document).ready(function () {
        $(".AutoC").each(function() {
  var id = $(this).attr("id");
    $(this).autocomplete('@Url.Action("Liczba_wejsc", "Home")', { minChars: 1, selectFirst: true, extraParams: { "ID": id} });
    });
});
    </script> 

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Continuously running React useEffect even with an empty dependency array

In my React application, I have implemented a hook system. Each sub-hook that is generated within this main hook is assigned a unique ID automatically. This ID is incremented by 1 every time a new sub-hook is created, ensuring uniqueness. const App = ...

Implementing a Singleton Pattern in ReactJS using Context API for Asynchronous Operations

My current implementation involves using a hook: function useFollowUser() { const isFollowing = useRef(false); return (userId) => { if(isFollowing.current) return; // mutual exclusion isFollowing.current = true; ... updat ...

Encountering timeout issues with Next.JS fetch and Axios requests on Vercel production environment

I've been encountering an issue where I am unable to fetch a specific JSON data as it times out and fails to receive a response on Vercel deploy. The JSON data I'm trying to fetch is only 18KB in size and the fetch request works perfectly fine in ...

What method can I use to locate the double quote option within an HTML select element using jQuery?

Here is an example of the select: <select id="id0" name="name0"> <option value='30" size'> 30" size </option> </select> The select contains double quotes. I am trying ...

"Strategies for identifying the presence of a return value or null in jQuery AJAX

Currently, I am utilizing a jQuery post ajax request to perform an action. The page 'submit.php' sends back a JSON value, and sometimes if there is a fatal error it returns nothing. I am struggling to determine whether the ajax call returns a va ...

Unable to produce scrolling animation using JavaScript

I'm trying to implement a feature on my website where the page scrolls with a sliding effect when the user presses the "Scroll" button. However, I've encountered issues as it doesn't seem to work despite adding the necessary tags to my HTML ...

Debugging TypeScript on a Linux environment

Approximately one year ago, there was a discussion regarding this. I am curious to know the current situation in terms of coding and debugging TypeScript on Linux. The Atom TypeScript plugin appears promising, but I have not come across any information ab ...

align all items centrally and customize Excel columns based on the length of the data

Is there a way to dynamically adjust the column width based on the length of data in an Excel report using PHPexcel? Additionally, how can I center all the data in the Excel sheet? Here is the current code snippet: <?php if (!isset($_POST['send&a ...

jQuery - Resolving the Conflict

My current challenge seems to be related to the scope of my approach. I've noticed that either the slider works, or the images replace text, but not both at the same time. The inclusion of the "scrollbox.min.js" file is necessary for the slider to f ...

Modifying the color of multiple cells simultaneously

I'm currently facing an issue where I need to change the cell color of multiple cells at once, all stored within a specific range. However, I only want certain cells to change based on a particular condition. While I can manually change each cell, it& ...

No data being displayed or returned from API when using async await

My Ionic 6 + Angular 14 application is currently facing an issue with displaying data retrieved from an API... I have implemented a service to fetch the data from the API and then called this service in the component. The app compiles without any errors a ...

My table elements are automatically being populated with <tr> elements thanks to Javascript

Upon viewing the screenshot: https://i.sstatic.net/Pwv2v.png it is evident that each element is placed within its own tr. My preference is to have each element contained in a td and then wrap everything within a single tr. Here is the updated HTML stru ...

Using ReactJS to showcase information pulled from a .txt file located on a specific URL

I am looking to present data from a .txt file that is uploaded on a specific URL within my React application. The URL is part of a JSON object that I retrieve using the Fetch function and store in my state. To display the URL, I currently use: {this.state ...

Make the cursor move in sync with an already moving element

I'm trying to create an element with a breathing animation effect that also follows the cursor. However, I'm running into an issue where the code only works if I remove the animation in CSS. What am I doing wrong? It seems like your post is mos ...

Struggling to design a functional mobile keyboard

I've been working on creating a mobile keyboard, but I'm facing some issues with the JavaScript part. The problem seems to be in my code as the keyboard isn't responding when I try to type. Here's a snippet of the JavaScript I'm us ...

Executing Multiple Ajax Requests Concurrently with Single Callback in jQuery

I am experimenting with ways to improve page loading speed by breaking up all the database calls into separate scripts and executing them simultaneously using ajax. After doing some research, I discovered that jQuery's $.when().then() function could h ...

Learn how to establish a state using an array and effectively utilize the setState() method in React

For my latest project, which is API based, I am working with arrays that contain sub-arrays. How can I define a state with an array and utilize the setState() method to work with the entire array? ...

In the context of Express, how are "static" and "non-static" defined?

The Express documentation explains that the express.static() middleware is used to serve static files like images, CSS, and JavaScript. However, when serving a front-end React app using express.static("some_build_dir"), which includes JS files ...

Frontend is refusing to remove items from the shopping cart, while the backend is functioning properly in doing so

I've been working on a shopping cart project using Vanilla JS. The interface handles DOM logic, while the backend deals with array manipulation. The issue I'm facing is with a button that's supposed to remove items from the cart. Despite pa ...

Unforeseen alterations in value occur in JavaScript when converting to JSON format

Having trouble generating a gantt chart from a JSON string, specifically with parsing the JSON string into a JSON object. I have a variable myString containing a JSON string that looks like this: {"c": [{"v": "496"}, {"v": "Task name 1"}, {"v": "9, "}, { ...