form element not showing up after adding in through jquery

Posted by ooo on Stack Overflow See other posts from Stack Overflow or by ooo
Published on 2010-05-13T11:47:54Z Indexed on 2010/05/13 11:54 UTC
Read the original article Hit count: 159

Filed under:
|

inside a jquery method (on a click event of a button) i have the following code:

    $(selector).html("<form action='/Tracker/CopyFood' method='post'><input type='hidden' name='Id' value=" + id + "><input class='very-small-input' type='text' name='Quantity' value='1' /> for <select name='Date'><option value='Today'>Today</option><option value='Yesterday'>Yesterday</option></select><select name='Meal'><option value='Breakfast'>Breakfast</option><option value='Lunch'>Lunch</option><option value='Dinner'>Dinner</option><option value='Evening Snack'>Evening Snack</option></select><input type='button' class='submitCopyFood' value='Add'> or <div style='display:inline' class='CancelCopy'>Cancel</div></form> ");

it seems to work on the screen, but the button click "submitCopyFood" wasn't firing. When i click "View Selection Source" in firefox, i see the issue. All i see is this:

   <input name="Id" value="128" type="hidden"><input class="very-small-input" name="Quantity" value="1" type="text"> for <select name="Date"><option value="Today">Today</option><option value="Yesterday">Yesterday</option></select><select name="Meal"><option value="Breakfast">Breakfast</option><option value="Lunch">Lunch</option><option value="Dinner">Dinner</option><option value="Evening Snack">Evening Snack</option></select><input class="submitCopyFood" value="Add" type="button">  or <div style="display: inline;" class="CancelCopy">Cancel</div>

Its like i never added the form anywhere. Is there any reason why i dont see the:

<form action='/Tracker/CopyFood' method='post'>

or the

</form>

in the source code inside the selected source. Is there something special that i need to do here?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about forms