Bug Tracker

Opened 11 years ago

Closed 9 years ago

#3229 closed enhancement (fixed)

val: setting should check to see if this.value is a function so plugins can use it

Reported by: DylanGreene Owned by:
Priority: trivial Milestone: 1.3
Component: attributes Version: 1.2.6
Keywords: val, value, setter, getter Cc: DylanGreene, flesler
Blocked by: Blocking:

Description

Currently val uses this to set the value

this.value = value;

This means plugin authors can't easily use val because we can't run a function when the value is changed.

This change would make it so that if this has a setter function it will use it:

if ( jQuery.isFunction( this.value ) )
 this.value( value );
else 
 this.value == value;

The same change should happen for the getter.

Change History (3)

comment:1 Changed 11 years ago by flesler

Cc: DylanGreene flesler added
need: ReviewTest Case

val does a lot of things, we'd need to add this check many times. For this case (just setting the value) you can use .attr() which is actually a faster way.

attr() supports functions. I think this enhancement is not needed.

Can you provide a test case that shows a real need for this, and that attr() can't be used ?

comment:2 Changed 9 years ago by dmethvin

Component: coreattributes

comment:3 Changed 9 years ago by dmethvin

Resolution: fixed
Status: newclosed

Implemented in 1.4.

Note: See TracTickets for help on using tickets.