Bug Tracker

Custom Query (13852 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (64 - 66 of 13852)

Ticket Resolution Summary Owner Reporter
#4924 invalid Use .val( true ) to return option.text instead of option.value ALLPRO
Description

I often need to retrieve the 'display text' for the selected OPTION in a SELECT.

CURRENTLY, the text is only returned if the OPTION has no value...

return (elem.attributes.value || {}).specified ? elem.value : elem.text;

It would be useful if returning elem.text could be forced by passing 'true' as the value param.

This assumes 'true' is not a valid setter 'value'. This seems to be the case as far as I can tell.

I think it intuitive that 'true' would be a getter 'parameter' and not a setter 'value'. It's not unusual for booleans to be used this way.

My suggested change addes a 'retText' flag that is used to decide whether to return 'value' or 'text'. Here are the changed sections:

1.3.2 - line 409 - add & use retText flag

val: function( value ) {
    var retText = value === true;
    if ( value === undefined || retText ) {
        var elem = this[0];

        if ( elem ) {
            if( jQuery.nodeName( elem, 'option' ) )
                return (elem.attributes.value || {}).specified && !retText ? elem.value : elem.text;

1.3.2 - line 433 - pass retText back to val()

    if ( option.selected ) {
        // Get the specific value for the option
        value = jQuery(option).val( retText );

ALTERNATIVELY, passing 'true' could return a hash containing BOTH value and text, like...

return { value: elem.value, text: elem.text };

This is just pseudo-code - would have to validate that option.value exists. Best to slightly restructure existing validation to avoid repeating it.

Returning a hash avoids 2 calls to retrieve both value and text, just as offset returns both top & left. It is still simple to use when you *only* want the text...

var text  = $('#mySelect').val( true ).text

Either format would address the need to retrieve option.text. The first method is simpler because it returns a single value, but the second method is more versatile.

As long as 'true' is not a valid setter value, this enhancement provides new versatility without any problems or compatibility issues.

/Kevin Dalman

#5326 worksforme Cannot unbind mouseenter/mouseleave events using a 'namespace' ALLPRO ALLPRO
Description

The unbind(".NAMESPACE") functionality does not work for the mouseenter and mouseleave pseudo-events.

$(el).bind("click.mywidget");

$(el).bind("mouseenter.mywidget");

$(el).unbind(".mywidget"); unbind

This unbinds "click.mywidget", but NOT "mouseenter.mywidget".

Even if the event name is added, mouseenter still won't unbind when the namespace is specified...

$(el).unbind("mouseenter.mywidget"); does not work

The only way to unbind mouseenter is to *not* specify the namespace - ie, unbind *all* mouseenter events...

$P.unbind("mouseenter"); works normally

The same thing applies to mouseleave.

The main issue here is that unbinding an event.namespace *should* unbind ALL events that were added using bind("event.namespace").

FYI: I posted this in the dev-forum for feedback, but got no response:

http://groups.google.com/group/jquery-dev/browse_thread/thread/dc9610de500e6cec/c16d3307ff8c93c2?hl=en#c16d3307ff8c93c2

#7986 fixed Bug in $.support.boxModel if page has DIV-element CSS ALLPRO
Description

I have a demo page for a plugin that, for simplicity, has a CSS rule like this...

div { padding: 15px; border: 1px solid #999; }

This div rule BREAKS jQuery's $.support logic. The existing jQuery 1.4.4 code is like this...

div.style.width = div.style.paddingLeft = "1px";
...
jQuery.support.boxModel = div.offsetWidth === 2;

Because ONLY the leftPadding is specifically set, the DIV inherits defaults for other settings, which causes boxModel, inlineBlockNeedsLayout and shrinkWrapBlocks to be set WRONG in every browser.

It is not common for DIVs to have default styling set, but it is not unreasonable either. Therefore jQuery should handle this use-case by *specifically setting all relevant styles* to avoid errors - ie...

var s = div.style
s.width = s.padding = "1px";
s.border = 0; s.overflow = "hidden";
...
jQuery.support.boxModel = div.offsetWidth === 3;

In the sample above, padding is applied both left & right, so all tests in this section must be changed from '===2' to '===3'. OR paddingRight could be set to 0, but this requires extra code.

This may be a rare bug, but it takes less than a minute to fix it, so hopefully it won't be ignored.

Note: See TracQuery for help on using queries.