Modify ↓
Ticket #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@… | |
| Blocking: | Blocked by: |
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

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