使用jq_form_remote_tag刷新div

时间:2012-07-31 13:36:13

标签: jquery ajax symfony1 symfony-1.4

两张照片。问题看看下面。

enter image description here

enter image description here

我的模板中有以下代码 - 再次感谢j0k:

<div id="listdiv">
echo jq_form_remote_tag(array(
    'update' => 'listdiv',
    'url' => 'shoppinglist/update',
    'loading' => jq_visual_effect('fadeIn', '#indicator'),
    'complete' => jq_visual_effect('fadeOut', '#indicator'),
));
</form>
</div>

当我在空白字段中键入“apple”并提交表单(第一张图片)时,所有内容都将正确保存在数据库中。结果是图二。但新领域并未出现。有什么想法吗?

如果我进行完全刷新,番茄,苹果和新文本字段正确显示!

我关闭了action.class.php中的所有if-method-GET / POST语句。有人有想法吗?

更新

action.class.php

public function executeIndex(sfWebRequest $request) {
$endkunde_id = $this->getUser()->getAttribute('id');
$zustand_id = 1;

$list_id = 252;
$shopname_id = 1;
$shopname = 'shop 1';

// if ($this->getRequest()->getMethod() == sfRequest::GET) {
    $this->form = new YourListForm(array(), array('endkunde_id' => $endkunde_id, 'list_id' => $list_id));
    $this->form2 = new AddOnYourListForm(array('shopname' => $shopname), array('endkunde_id' => $endkunde_id, 'list_id' => $list_id, 'shopname_id' => $shopname_id));
//  }

}

public function executeUpdate(sfWebRequest $request) {
$endkunde_id = $this->getUser()->getAttribute('id');
$zustand_id = 1;

$list_id = 252;
$shopname_id = 1;
$shopname = 'shop 1';

    $this->addon_listForm = new AddOnYourListForm();
    $addonlist = array();

    $p = 'addon_list_id_';
    $q = (string) 252;
    $p .= $q;

    $this->addon_listForm->bind($request->getParameter($p));
    if ($this->addon_listForm->isValid()) {
        $formData = $this->addon_listForm->getValues();
        // $this->addon_listForm->save();
    }

    $this->form = new YourListForm(array(), array('list_id' => $list_id, 'endkunde_id' => $endkunde_id));
    $p = 'yourlist_';
    $q = (string) 252;
    $p .=$q;

    $this->form->bind($request->getParameter($p));
    if ($this->form->isValid()) {
        $this->form->save();
        $this->form = new YourListForm(array(), array('list_id' => $list_id, 'endkunde_id' => $endkunde_id));
    }
}

1 个答案:

答案 0 :(得分:0)

我有一个解决方案:

简短说明:

action.class.php:

executeIndex{
if (method = post) {
 //handle the data
}
//here my index code above without method GET!!
}