Bug Tracker

Opened 10 years ago

Closed 10 years ago

#5013 closed enhancement (fixed)

Enhancement: val(callback)

Reported by: pmcelhaney Owned by:
Priority: minor Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc: pmcelhaney@…
Blocked by: Blocking:

Description

I was inspired by this question on Stack Overflow: http://stackoverflow.com/questions/1224133/1224191.

Modifying a val() on a form element feels a bit kludgy. If val took a function as an argument (which gets the original value and returns the new one), we could do things like this:

From the SO question

$('#abc').val(function(v) { return v + "test"; });

More realistic example

var formatPhoneNumber = function (input) { ... };

...

$('.phone').val(formatPhoneNumber); }

Change History (1)

comment:1 Changed 10 years ago by dmethvin

Resolution: fixed
Status: newclosed

This is in the nightlies already and should be in 1.3.3.

Note: See TracTickets for help on using tickets.