Reuse jquery in another control
<p>I have this jquery code inside a ASP.Net MVC 3 razor view</p>

<pre><code>var uriArticulos = '@Url.Action("ObtenerArticulos", "Articulo")';
$("#descripcionArticuloEditandoTextBox").autocomplete({
    source: uriArticulos,
    select: function (event, ui) {
        $("#idArticuloEditandoTextBox").val(ui.item.Id);
        $("#unitarioArticuloEditandoLabel").text(ui.item.Unitario);
    }
});
</code></pre>

<p>I need to use this autocomplete in a lot of places.
How can I reuse it in another control in other views in the same project whithout copy &amp; paste?</p>

<p>I'm trying this code, but nothing happens</p>

<pre><code>jquery.autoComplete.js

(function ($) {
    $.fn.articuloAutocomplete = function () {

        return this.each(function () {
            var $this = $(this);
            var uriArticulos = '@Url.Action("ObtenerArticulos", "Articulo")';
            $this.autocomplete({
                source: uriArticulos,
                select: function (event, ui) {
                    $("#idArticuloEditandoTextBox").val(ui.item.Id);
                    $("#unitarioArticuloEditandoLabel").text(ui.item.Unitario);
                }
            });

        });

    };
})(jQuery);
</code></pre>

<p>And I'm calling it with</p>

<pre><code>&lt;script src="@Url.Content("~/Scripts/jquery.articuloAutocomplete.js")" type="text/javascript"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
    $(document).ready(function () {
        $("#descripcionArticuloEditandoTextBox").articuloAutocomplete();
.
.
.
</code></pre>

<p>Thanks In Advance</p>
