Form submission by dynamically added button

Hi I added the submit button dynamically to the form using Jquery.

How can I assign contoller/action onclick event?

Please help

$(’<input type=“submit” style=“float:right;” id =“createteam” class=“g-button” value=“Create Your Team”/>’).appendTo(’#createTeam’);

I tried this…but its not working

$(’<input type=“submit” style=“float:right;” id =“createteam” class=“g-button” onclick=“function({jQuery.yii.submitForm(this,‘home/index’,{});return false;});” value=“Create Your Team”/>’).appendTo(’#createTeam’);

error

$("#createteam-form").yiiactiveform is not a function

Thanks,

Vic

instead of onClick why don’t you just define an ajax function such as:




jQuery(function($) {

jQuery('body').undelegate('input[id="createteam"]','click').delegate('input[id="createteam"]','click',function(){

jQuery.ajax({

                        'type':'POST',

                        'url':'/index.php?r=controller/action&param=value',

                        'cache':false,

                        'data':jQuery(this).parents("form").serialize(),

                        'success':

                            function(html){

                                some action here if you want

                            }});

return false;});

}



when you click the above button it should submit your form in ajax mode (…unless I have some syntax errors in the above example :P )