我有一些標籤其內容是我的網站的功能齊全的部分。codeigniter和標籤內容
例如,在我的管理區域,我有選項卡[添加/刪除相冊] [添加照片] [刪除照片]。我在技術上通過標籤劃分管理區域。
我正在使用ajax將內容加載到這些選項卡中。標籤內容區域是一個div。
的視圖裏的標籤內容區域也使用ajax來加載東西。 這些是在標籤內容區域內運行的ajax調用。
只要選項卡內容區域內的視圖保持不變或只有其中一部分發生更改,一切都可以正常工作。但是,當標籤內容區域內的某些交互返回全新視圖時,標籤內容區域將不會顯示它們。
我知道會發生什麼是這個返回的新視圖不會傳遞到選項卡內容區div。
在firebug中,我可以看到ajax成功函數響應顯示返回的新視圖。 但我不知道如何將新的視圖傳遞給標籤內容區域。
如果有人能幫我解釋如何解決這個問題,或者如何在CI中管理標籤內的內容,我將不勝感激。
adminTabsview.php
<ul id="adminTabs">
<li ><?php echo anchor('#album_addDelete', 'Album Add/Delete'); ?></li>
</ul>
<div id="adminTabsContent"></div>
$(document).ready(function(){
$('#adminTabs a').on({
click: function (evt){
evt.preventDefault();
var page = this.hash.substr(1);
adminTabsAjaxCall(page);
}
});
});
function adminTabsAjaxCall ($data){
$.ajax({
type: "POST",
url: "index.php/adminsite_controller/"+ $data + "/",
dataType: "html",
data: $data,
statusCode: {removed}
},
success: adminTabContent
});
function adminTabContent (data){
$('#adminTabsContent').html(data);
}
albumsEditDeleteView.php
(this is a view that gets loaded into the tab contentarea div)
<div id="adminTabsContent">
<div id="albumList">
<ul>
<li>
<a href="#">Asdf</a>
<a class="add" href="http://localhost/myPHP/photoalbums/index.php/Albums_Controller/add_album/301/Asdf/1/28/0">[ add ]</a>
<a class="delete" href="http://localhost/myPHP/photoalbums/index.php/Albums_Controller/delete_album/301/Asdf/1/28/0">[ delete ]</a>
</li>
</ul>
</div>
</div>
$(document).ready(function(){
$('#albumList').on({
click: function (evt){
evt.preventDefault();
var $clickedElement = evt.target.tagName;
if ($clickedElement == 'A'){
var urlarray = url.split('/');
$chosen.albumid = urlarray[8];
$chosen.albumname = urlarray[9];
$chosen.lft = urlarray[10];
$chosen.rgt = urlarray[11];
$chosen.nodeDepth = urlarray[12];
if ($class == 'add'){
albumajaxcall($chosen);
}
if ($class == 'delete'){
deleteajaxcall($chosen);
}
}
}
});
});
function albumajaxcall($data){
$.ajax({
type: "POST",
url: "index.php/Adminsite_Controller/add_album/",
dataType: "json",
data: $data,
statusCode: {removed}
},
success: adminTabContent
});
}
function adminTabContent(data){
$('#adminTabsContent').html(data);
}
//heres the view file that has to replace the original view inside
//tabcontent area
//addnode_view.php
<?php echo form_open('Albums_Controller/update_albumSet');?>
<input type="text" name="newAlbum" id="newAlbum" value=""/>
<input type="submit" name="submit" value="Submit" />
<?php echo form_close();?>
<?php
//heres the controller function
function add_album(){
$levelData ['albumid'] = $this->input->post('albumid');
<!-- removed-->
$levelData ['main_content'] = 'addnode_view';
$this->load->view('includes/template', $levelData);
}
//And heres the controller method that loads
//the original page (albumsEditDeleteView.php) - this is the original view
//that gets loaded into the tab- I get stuck when this view
//has to be **totally** replaced through links in the view)
function album_addDelete(){
$allNodes ['myAlbumList'] = $this->Albums_Model->get_albumList();
echo $this->load->view('albumsEditDelete_view', $allNodes);
}
thanx提前。
如果你澄清了你所問的問題,它不會受到傷害。另請發佈相關代碼。 –
如何將新視圖傳遞給標籤內容區域? –
第二次讀這個問題,仍然有點模糊,但感謝您的代碼。 1.你有沒有從adminTabContent中發出「數據」來查看它是否填滿了某些東西? 2.你確定你想在adminTabsAjaxCall中使用php風格的「$ data」嗎? 3.一目瞭然,它看起來像ajax代碼中有一個額外的}? – MikeCruz13