Yii Framework Forum: Ajax callback function not called with ajaxSubmitButton - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax callback function not called with ajaxSubmitButton Rate Topic: -----

#1 User is offline   Nanel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 29-April 10

Posted 30 April 2010 - 12:04 AM

I can't get a CHtml::ajaxSubmitButton to do the callback on success/error/beforeSend/complete.

Here is the code I'm using for testing purpose within my view:

<?php
echo CHtml::beginForm();
echo CHtml::textField('My label', 'my value');

$options = array(
 'beforeSend' => 'js:function(XMLHttpRequest) { alert("before send"); }',
 'success' => 'js:function(data, textStatus, XMLHttpRequest) { alert("success"); }',
 'error' => 'js:function(XMLHttpRequest, textStatus, errorThrown) { alert("error"); }',
 'complete' => 'js:function(XMLHttpRequest, textStatus, errorThrown) { alert("complete"); }'
);

echo CHtml::ajaxSubmitButton('Ajax submit button', CHtml::normalizeUrl(array('controller/action'), $options));
echo CHtml::ajaxButton('Ajax button', CHtml::normalizeUrl(array('controller/action')), $options);
echo CHtml::ajaxLink('Ajax button', CHtml::normalizeUrl(array('controller/action')), $options);

echo CHtml::endForm();

?>


It does work as expected for ajaxButton and ajaxLink but NOT for ajaxSubmitButton.

Has anyone encountered this issue before? Any solution?

Thanks for your time.
0

#2 User is offline   resplendent 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 22-May 09
  • Location:Singapore

Posted 30 April 2010 - 01:53 AM

It is because your normalizeUrl for the ajax submit button bracket is not closed. By the way, you just have to put array('controller/action') instead of CHtml::normalizeUrl(array('controller/action')).
0

#3 User is offline   Nanel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 29-April 10

Posted 03 May 2010 - 01:59 AM

View Postresplendent, on 30 April 2010 - 01:53 AM, said:

It is because your normalizeUrl for the ajax submit button bracket is not closed. By the way, you just have to put array('controller/action') instead of CHtml::normalizeUrl(array('controller/action')).


You well spotted the unclosed (closed later actually) bracket.

Thanks for the tips about the unnecessary normalizeUrl call.

Thanks for your time.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users