AjaxSubmitButton and Jquery Validation Bug

Hi guys,

I’m using the validation plugin from Jquery to be sure that the datas submitted will not be empty.

Everything worked fine with


CHtml::submitButton('Submit')

, but as soon a i changed this

to


CHtml::ajaxSubmitButton('Submit',CController::createUrl('book/add'),array(

                          'update'=>'#book-div',

                          'cache'=>true,

              'beforeSend' => 'function(){

                $("#book-div").addClass("loading");}',

              'complete' => 'function(){

                $("#book-div").removeClass("loading");}',

            ),

           array(

              'id'=>'ajax-book-button',

           )

          )



, the validation is ignored.

My javascript code:


<script type="text/javascript">

	    // only for demo purposes

	    $.metadata.setType("attr", "validate");

	

	    $(document).ready(function () {

	        $("#search-book").validate();

	    });   

		</script>

The javascript generated by the AjaxSubmitButton:


<script type="text/javascript">

/*<![CDATA[*/

jQuery(function($) {

jQuery('body').delegate('#submit-book','click',function(){jQuery.ajax({'cache':false,'beforeSend':function(){

$("#book-div").addClass("loading");},'complete':function(){

$("#book-div").removeClass("loading");},'type':'POST','url':'/index.php?r=book/search','data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#book-div").html(html)}});return false;});

});

/*]]>*/

</script>

Do i miss something here? or do you have an idea how can i keep the validation working even with the Ajax Submit Button ?

Thanks

Duplicate post - http://www.yiiframework.com/forum/index.php?/topic/19653-

hi mdomba

sorry i am posting here

i need your help i m new in yii framework but then also i complete 3 projects in yii

now in my new project i am stuck with 2 points which is

1- cgridview filter with autocomplete feature

2- cgridview row click will redirect user to view page and if user click on checkbox then it will not redirect

i’ll be very thankful if you could help me

Nadeem… please understand one thing… this is a forum… not a support board…

so you don’t need to ask directly me for help… and it’s not a good practice…

If you have a problem… post the question in the forum and if anybody had a similar problem or if anybody knows how to solve it… (and if they have time)… be sure that they will try to help you… (me included)

If you don’t get a response in a day or two… post on the same thread with more info and/or with some more details about what you tried until now… DO NOT open a new thread for the same problem…

One more thing to understand… you cannot expect that someone will solve your problems… you can only expect to get new ideas and guides in solving the problem… but in the end is you the one that needs to understand the process and code your application…

sorry for this i’ll take care of this next time

I quote mdomba.

Btw, I ansered you in the original thread.

It’s not really a duplicate post, i changed the title to be more accurate and i added more content to my original thread :)

@persia… this is considered duplicate post as the problem is the same… you can always edit your orignila post to add more content… and to change the title…

there is no need to open new posts… as this way it would be difficult to trace answers to both posts…

Ok, sorry, next time i will edit :) cause i was not able to edit the title

Thank you… I understand that…

To edit the title you have to click on "use full editor" while editing the first post of a thread…