Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
jQuery.css returns a string
19/08/2009
11:08
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

There are a few cases where the result of jQuery.css is being used as if it were of type jQuery. IE8 (and probably others) doesnt like that:

grid.base.js:1086

$(eg).css("width",grid.width+"px").append("<div class='ui-jqgrid-resize-mark' id='rs_m"+ts.p.id+"'>&nbsp;</div>");
similarly line 1106.
Mark
19/08/2009
11:55
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Sorry, but I think that this is not true.

Here is the jQuery css:

    css: function( key, value ) {
        // ignore negative width and height values
        if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
            value = undefined;
        return this.attr( key, value, "curCSS" );
    },

And here the attr

    attr: function( name, value, type ) {
        var options = name;

        // Look for the case where we're accessing a style value
        if ( typeof name === "string" )
            if ( value === undefined )
                return this[0] && jQuery[ type || "attr" ]( this[0], name );

            else {
                options = {};
                options[ name ] = value;
            }

        // Check to see if we're setting style values
        return this.each(function(i){
            // Set all the styles
            for ( name in options )
                jQuery.attr(
                    type ?
                        this.style :
                        this,
                    name, jQuery.prop( this, options[ name ], type, i, name )
                );
        });
    },

So if we set value the css return this.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

19/08/2009
15:30
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

Sorry, you're right... except that there appears to be a minor bug in jQuery.

If you're setting height or width, and you pass in a -ve value, (eg $("#foo").css("width", "-4px"), then it goes through the "undefined" case in the above, which then /returns/ the width, rather than setting the width, and returning a jQuery.

That's what was happening, and I just jumped to the conclusion that css always returned a string.

So now I need to track down how colModel[i].width gets to be < 0. I think it has something to do with autowidth.

In any case, its probably my bug (in that it doesnt show up in firefox) - but I'd still say that its a good idea not to chain the css method when setting width/height by name unless you're certain the width/height is >= 0.

Mark

21/08/2009
01:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello Mark,

Thanks for this. I do not know about this bug. Will try to set the css at end of the expressions, where possible, but I think that this will be fixed in the next release of jQuery.

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
87 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information