couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Fresh (JIRA)" <>
Subject [jira] Commented: (COUCHDB-924) The populate function in jquery.editinline.js isn't bound to elem
Date Mon, 08 Nov 2010 17:41:16 GMT


Andrew Fresh commented on COUCHDB-924:

The problem is that the populate function only gets the current text of the element to be
edited and that is not what I want to edit but the function currently does not provide a way
to get the content I do want to edit.

What I have is 
<div id="amount">{{amount_formatted_with_commas}}</div>

So, I want to look up the numeric amount to edit instead of the formatted value (see the populate
function in the original description).

This also allows me to set the content to be "No amount set" if the value is null but not
have that text pre-populate the textbox.

The patch allows someone to look up the content to edit based on some characteristic of the
element it is being applied to instead of relying only on the text content of that element.
It does this by applying the function to the element instead of just calling it with the text
of the element.  It should not cause any change to the existing use of the function, just
add additional capabilities.

> The populate function in jquery.editinline.js isn't bound to elem
> -----------------------------------------------------------------
>                 Key: COUCHDB-924
>                 URL:
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: HTTP Interface
>            Reporter: Andrew Fresh
>            Priority: Minor
>   Original Estimate: 0.17h
>  Remaining Estimate: 0.17h
> I wanted a populate function like this and it didn't work that way.                 
> populate: function(value) { return doc[ ] },                                
> So, I came up with the patch below.  It looks like the rest of the                  
> options functions get called the way I changed it, so I am not sure if              
> there was a specific reason that one got to be different, but I like it             
> better this way.                                                                    
> Index: share/www/script/jquery.editinline.js                                        
> ===================================================================                 
> --- share/www/script/jquery.editinline.js       (revision 1022364)                  
> +++ share/www/script/jquery.editinline.js       (working copy)                      
> @@ -15,7 +15,7 @@                                                                   
>    function startEditing(elem, options) {                                           
>      var editable = $(elem);                                                        
>      var origHtml = editable.html();                                                
> -    var origText = options.populate($.trim(editable.text()));                      
> +    var origText = options.populate.apply(elem, [$.trim(editable.text())]);        
>      if (!options.begin.apply(elem, [origText])) {                                  
>        return;                                                                      

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message