Bug Tracker

Ticket #3229 (new enhancement)

Opened 3 months ago

Last modified 3 months ago

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

Reported by: DylanGreene Assigned to: anonymous
Type: enhancement Priority: trivial
Milestone: 1.3 Component: core
Version: 1.2.6 Keywords: val, value, setter, getter
Cc: DylanGreene, flesler Needs: Test Case

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.

Attachments

Change History

Changed 3 months ago by flesler

  • cc set to DylanGreene, flesler
  • need changed from Review to Test 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 ?

Note: See TracTickets for help on using tickets.