Bug Tracker

Modify

Ticket #5013 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

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

comment:1 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.