jQuery/javascript object passing
<p>Up until this point, I haven't done much in javascript.  I recently started playing with jQuery and came across a tutorial on how to do <a href="http://docs.jquery.com/Tutorials:Edit%5Fin%5FPlace%5Fwith%5FAjax" rel="nofollow">Edit in Place</a> on a form.</p>

<p>The resulting code works perfectly if you hard-code the id of your container div in the function, but I'm having issues generalizing it for an id passed in to the function.</p>

<p>The code starts like this:</p>

<pre><code>$(document).ready(function() {
    setClickable($('#editInPlace'));
});

function setClickable(target)
{
    $(target).click
    (
     function()
     {
      //Do some dom manipulation

      $('.buttonA').click(function() { saveChanges(this, false); });
      $('.buttonB').click(function() { saveChanges(this, true); });
     }
    )

    .mouseover(function() { $(this).addClass("editable"); })
    .mouseout(function() { $(this).removeClass("editable"); });
}; //end of function setClickable

function saveChanges(obj, cancel)
{
    //Handle the save changes code

    //Reset the div
    $(obj).parent().after('&lt;div id="editInPlace"&gt;' + t + '&lt;/div&gt;').remove();

    //Call setClickable
    setClickable($('#editInPlace'));
}
</code></pre>

<p>The part I'm having issues with is the last call to <code>setClickable</code> inside of the <code>saveChanges</code> function.  If I hard-code the value of <code>$('#editInPlace')</code>, it works fine.  However, if I change the function signature to </p>

<pre><code>function saveChanges(target, obj, cancel)
</code></pre>

<p>and pass in the target object from the setClickable method:</p>

<pre><code>$('.buttonB').click(function() { saveChanges(target, this, true); });
</code></pre>

<p>calling </p>

<pre><code>setClickable(target);
</code></pre>

<p>doesn't seem to work and I can't figure out why.</p>
