Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c.curCSS is not a function bug from jQuery

Tags:

jquery

I am getting this errors message in console.

c.curCSS is not a function
...,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m...

This my function who does the autocomplete:

function autocomplete_name (name_val, id_val,action, button) {

        $(document).ready(function () {
            $(name_val).autocomplete({
                source: function( request, response ) {
                    $.ajax({
                        url: action,
                        dataType: "json",
                        data: {
                            term: request.term

                        },
                        success: function( data ) {
                            response( $.map( data, function( item ) {
                                return {
                                    label: item.name,
                                    value: item.name,
                                    id: item.id
                                }
                            }));
                        }
                    });
                },
                minLength: 2,
                select: function( event, ui ) {
                    $(id_val).val(ui.item.id);
                    $(name_val).val(ui.item.value);
                    $(button).trigger("click")
                }
            });

        });

}

I have jQuery 1.8.3 version and I do not have access to the file. It is from another server, I just use a link to the library. The function works, but there is no css apply to the results and i am getting that error message in console. YES I saw solutions that I have to modified the library, but I do not have acccess to do that. What should I do in order to make this work.

like image 978
Jozsef Naghi Avatar asked Mar 27 '15 10:03

Jozsef Naghi


1 Answers

As a workaround, you could simply redefine $.curCSS() in your module.

After including jQuery, write something like:

jQuery.curCSS = function(element, prop, val) {
    return jQuery(element).css(prop, val);
};

jQuery UI will end up calling that function afterwards, and the autocomplete widget will work as intended.

Update: I just realized my answer is a quasi-duplicate of Johann Chaves Saborío's answer there. I will leave it here, though, because my function propagates the return value of $.css() to the caller, but his doesn't.

like image 126
Frédéric Hamidi Avatar answered Sep 26 '22 04:09

Frédéric Hamidi