0
我有一個彈出式菜單,可以在此刻打開並顯示文本。我想要的是能夠將控制器連接到彈出菜單。例如:我想要一個編輯配置文件彈出窗口來顯示所有必要的輸入來編輯配置文件。AJAX - 如何在彈出式菜單中運行腳本
userprofile_view.php:
<div class="upload">
<?php
$data = array('id' => 'test');
echo form_open('', $data);
echo form_submit('upload', 'Upload');
echo form_close();
?>
</div>
<div id="popupbox">
<center>
<p class="head">Terms and Conditions</p>
<p class="term_full">By entering your email, you allow Musiclear to send you information regarding Musiclear and
related services <br><br> By entering your email, you also understand that you can break our hearts and unsubscribe
at anypoint. <br><br> And feel free kick us if we ever share your email address (you can trust us)</p>
</center>
</div>
這是按鈕,在彈出的形式背後的HTML。
main.js:
$("#test").submit(function(event) {
event.preventDefault();
document.getElementById('popupbox').style.visibility="visible";
});
點擊按鈕我使窗體可見。
如何使用彈出式菜單中的表單進行此項工作?
編輯:
上傳控制器(我想在彈出顯示什麼):
function do_upload_profilepicture()
{
$this->load->model('model_users');
$userID = $this->model_users->getUserID($this->session->userdata('username'));
$config['upload_path'] = './img/profilepictures/';
$config['allowed_types'] = 'jpg|png';
$config['overwrite'] = TRUE;
$config['file_name'] = $userID;
$config['max_size'] = '500';
$config['max_width'] = '1920';
$config['max_height'] = '1028';
$this->load->library('upload', $config);
if (! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_profilepic_form', $error);
}
else
{
$upload_data = $this->upload->data();
$resize['image_library'] = 'gd2';
$resize['source_image'] = $upload_data['full_path'];
$resize['maintain_ratio'] = FALSE;
$resize['width'] = 180;
$resize['height'] = 180;
$this->load->library('image_lib', $resize);
$this->image_lib->resize();
$this->image_lib->clear();
$this->model_users->setProfilePic($userID, $upload_data['orig_name']);
$this->create_thumb($upload_data['orig_name']);
redirect('userprofile/home/' . $userID);
}
}
userprofile_view.php(popupbox):
<div id="popupbox">
<?php echo form_open_multipart('upload/do_upload_profilepicture');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
</div>
優化此?這不需要優化。你在問如何爲彈出窗口添加功能? – 2014-10-20 16:04:55
對不起,錯誤的措辭ima改變了 – Divergent 2014-10-20 16:05:20
添加彈出菜單的功能與添加事件處理程序沒有什麼不同,就像您爲'#test'所做的一樣。 – 2014-10-20 16:06:25