0

次のHTMLコードがあります

<div id="form_target"></div>

<form action="?r=index/login" target="#form_target"></form>

actionLogin からテキストを返し、それを form_target に表示したいと考えています。どうやってするか?

私が試してみました

$this->renderText($Respond);

それでも失敗しました。ブラウザーで、返されたテキストを示す新しい画面が表示されました。form_target 内のテキストが必要です。

ありがとうございました。


UITableView 内の画像を更新できません

テーブルビュー内の画像を変更しようとしています。私は[myTableView reloadData];別の方法(起動中)を使用してリフレッシュしていTableViewますが、テーブルビューの他の要素がリフレッシュされていることがわかりますが、画像は同じままです。私は何が欠けていますか?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    UILabel *lblName;
    UIImageView *checkMark = [[UIImageView alloc] initWithFrame:CGRectMake(230, 0, 30, 50)];
    if (cell == nil) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
        UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(10, 1, 260, 70)];
        backgroundView.backgroundColor = UIColorFromRGB(0x000000, 0.3);
        backgroundView.userInteractionEnabled = YES;        

        checkMark.image = [UIImage imageNamed:@"V.png"];
        checkMark.contentMode = UIViewContentModeCenter;
        checkMark.backgroundColor = [UIColor clearColor];
        [backgroundView addSubview:checkMark];
        [checkMark release];

        [cell.contentView addSubview:backgroundView];
        [backgroundView release];
    }
    if (something)
    {
        checkMark.image = [UIImage imageNamed:@"halfleft.png"];
        NSLog(@"something was done");
    }
    return cell;

}
4

2 に答える 2

0

<form> タグを <div> タグに置き換えました。だから私は <form> タグなしでフォームエントリを送信します。そして、ajax post request を使用して値を送信します。

タグを使用しても、コントローラーから結果を取得するとページが更新され続ける理由を説明できません。

したがって、変更された html コードは次のようになります。

<div id="form_target"></div>

<div id="form">
  <input .../>
  <input .../>
  <input .../>
  <input type="button" value="submit" onclick="SubmitForm();"/>
</div>

SubmitForm() は次のようになります

SubmitForm()
{
  var data = $("#form *:input").serialize();

  $.post(
    url,
    data,
    function(data)
    {
      $("#form_target").html(data['respond_text']);
    },
    'json'
  );
}
于 2013-02-18T03:24:01.620 に答える
0

$this->renderText($Respond)をに置き換えecho $Respondます。のAPIページからrenderText()

静的テキスト文字列をレンダリングします。文字列は現在のコントローラー レイアウトに挿入され、返されます。

于 2013-02-17T09:54:50.130 に答える