E
E
EVOSandru62015-10-21 11:43:18
JavaScript
EVOSandru6, 2015-10-21 11:43:18

How to merge data attributes in ajaxSubmitButton?

Good afternoon, there is such a bandura:

echo CHtml::ajaxSubmitButton
(
    $model->isNewRecord ? 'Добавить номера' : 'Обновить',

    Yii::app()->createUrl('sadmin/hotels/ajaxCreate'),
    [
        'type'=>'POST',
        'data'=>'js:$("#add-user-form").serialize()',
        // Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken
        'success'=>'js:function(data)
        {alert(data);}',
    ],


How can I correctly syntactically merge into data - Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken and 'js:$("#add-user-form"). serialize()' ? So that it and then fly away.

If without js serialization, then it is clear:

'data'=>
[
        Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken
]


And in my case I'm having a hard time

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor, 2015-10-29
@EVOSandru6

since serialize() returns a string, then you can do

'js:$("#add-user-form").serialize()+"&'.Yii::app()->request->csrfTokenName.'='.Yii::app()->request->csrfToken.'"'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question