2011-11-28 65 views
3

我第一次使用jQuery Mobile Framework。我已經從站點複製了一個listview的示例代碼。根據文檔,它應該做一個AJAX調用,然後更新DOM。PHP jQuery手機listview鏈接返回「undefined」

當我點擊鏈接時,ajax加載圖標彈出正確。頁面然後重新加載其中唯一的單詞「未定義」。

我正在使用CakePHP,它已經拉入我的移動佈局。如果我重新加載頁面,我會得到正確的頁面視圖。

有人可以建議這個「未定義」的消息來自哪裏以及如何得到這個工作?

感謝, 安迪

編輯:代碼包括

// mobile layout 
<div data-role="page" class="type-interior">    
    <div class="content-primary"> 
      <p><?php echo $content_for_layout; ?></p> 
    </div><!-- /content -->  
</div><!-- /page --> 


// gallery view 
<div data-role="header"> 
    <h1>My heading</h1> 
</div><!-- /header --> 
<ul data-role="listview" data-filter="true"> 
<li><?php echo $this->Html->link('Gauteng',array('controller'=>'regions','action'=>'gallery',4)); ?></li> 
    <li><?php echo $this->Html->link('Western Cape',array('controller'=>'regions','action'=>'gallery',1)); ?></li> 
    <li><?php echo $this->Html->link('Eastern Cape',array('controller'=>'regions','action'=>'gallery',2)); ?></li> 
    <li><?php echo $this->Html->link('Northern Cape',array('controller'=>'regions','action'=>'gallery',9)); ?></li> 
    <li><?php echo $this->Html->link('Free State',array('controller'=>'regions','action'=>'gallery',3)); ?></li> 
    <li><?php echo $this->Html->link('Mpumalanga',array('controller'=>'regions','action'=>'gallery',7)); ?></li> 
    <li><?php echo $this->Html->link('Kwa-Zulu Natal',array('controller'=>'regions','action'=>'gallery',5)); ?></li> 
    <li><?php echo $this->Html->link('North West',array('controller'=>'regions','action'=>'gallery',8)); ?></li> 
    <li><?php echo $this->Html->link('Limpopo',array('controller'=>'regions','action'=>'gallery',6)); ?></li> 
</ul> 

點擊這些結果在一個頁面,上面寫着 「未定義」 的。它具有移動版式,但沒有讀取正確的視圖文件。

編輯: 谷歌搜索廣泛發現了類似的問題answered here on stackoverflow但當我嘗試更改beforeRender方法的佈局,然後ajax永遠不會完成。我使用螢火蟲追蹤網絡流量,並可以看到http get請求已成功完成並返回正確的頁面信息(整個頁面)。但是,JQM不更新視圖。

+2

請發佈您的代碼。 –

+0

啊,在視圖中有一個腳本正在輸出。刪除腳本讓網站正常工作。 – Andy

+1

很抱歉再次發表評論,但我又遇到了這個問題,並認爲注意這裏的解決方案可能有助於人們。第二次遇到問題是因爲我使用的是CakePHP,並且需要在視圖文件的頂部包含正確的div標籤,以便AJAX調用可以檢測到傳入的內容。 – Andy

回答

0

我再次遇到這個問題,並認爲注意這裏的解決方案可能會幫助人們。第二次遇到問題是因爲我使用的是CakePHP,並且需要在視圖文件的頂部包含正確的div標籤,以便AJAX調用可以檢測到傳入的內容。