[eluser]Unknown[/eluser]
It works fine for me. I'm using PHP5, CI 1.6, xajax_0.5b4, und modalWindow_0.0.3 from amp-lified.de.
The trick is to set correct location for the javascript. As we see in line 124, modalWindow.inc.php
The path is hardcoded in this script.
--Step 1-- Directory Structure
Code:
mySite [top-level]
|-- system
|
|-- app
| |-- controller
| | testxajax.php
| |
| |-- init
| | init_xajax.php
| |
| |-- libraries
| | |-- xajax-core
| | xajax.php (moved from xajax-core/xajax.inc.php)
| | |-- xajax-plugins
| | | |-- response
| | | | modalWindow.inc.php (or anywhere)
| |
| |-- views
| | |-- test
|
|-- js (collection of all my javascript)
| |-- xajax-js
| |-- xajax-plugins
| | |-- response
| | | |-- modalWindow (hardcoded path)
| | | | modalWindow.js
--Step 2-- Configuration
--A--
we should go to line 248, xajax.php, alter:
$sLocalFolder = dirname(__FILE__)."/xajax_core";
--B--
index.php in root,
$application_folder = "../app";
--C--
From
CI Wiki
app/init/init_xajax.php
Code:
if ( ! class_exists('xajax') )
require_once(APPPATH.'libraries/xajax'.EXT);
--Step 3-- Views and Controller
Based on
wiki xajax perfect
--A-- Test modalWindow
app/views/test/test_xajaxplugin.php
Code:
<html>
<head>
<title>modal Window Plugin</title>
<?=$xajax_js?>
<style type="text/css">
body {
font-size: 10px; font-family: Arial, Helvetica, sans-serif;
color:#3F4752; background: #FFFFFF;
}
a { color:#3F4752; text-decoration:none; }
</style>
</head>
<body>
<h1>modal Window</h1>
<input type="button" onclick="xajax_testWindow();" value="show modal window" />
</body>
</html>
--B-- Testing Controller
Here comes the best part.
app/controllers/testxajax.php
Code:
<?php
Class Testxajax Extends Controller {
function __construct () {
parent::__construct();
$this->load->library('xajax');
$this->xajax->setFlag("debug", true);
require_once( APPPATH.'libraries/xajax_plugins/response/modalWindow.inc.php');
}
//-- CI's Segment
public function modal() {
$this->xajax->register(XAJAX_FUNCTION, array('testWindow',&$this,'testWindow'));
$this->xajax->register(XAJAX_FUNCTION, array('actionClose',&$this,'actionClose'));
$this->xajax->processRequest();
$data['xajax_js'] = $this->xajax->getJavascript('../js/');
$this->load->view('test/test_xajaxplugin', $data);
}
//-- XAJAX's Function
public function testWindow() {
$objResponse = new xajaxResponse();
$objResponse->plugin( 'clsmodalWindow', 'addWindow',
$this->windowContentTest(), '#000000', 20 );
return $objResponse;
}
public function actionClose($data) {
// now you can close your window, or, if you want, open a new window
$objResponse = new xajaxResponse();
if ( $data['windowoption'] == 1 ) {
$objResponse->plugin( 'clsmodalWindow', 'addWindow',
$this->windowContentSubmit($data), 'red', 20 );
} else {
$objResponse->plugin( 'clsmodalWindow', 'closeWindow');
}
return $objResponse;
}
//-- Serve View
private function windowContentTest() {
$width = rand( 100, 500 );
$height = rand( 100, 500 );
$id = md5(microtime());
return '
<div style="width:' . $width . 'px;height:' . $height . 'px;
background:#FFFFFF;color:#000000;border:1px solid #999999;padding:5px">
<a href="[removed]void(0)" onclick="xajax.closeWindow()" >close</a><br/>
<a href="[removed]void(0)" onclick="xajax_testWindow()" >open new Window</a><br/>
<form id="' . $id . '" method="post" enctype="multipart/form-data">
<select name="windowoption" style="width:100px;">
<option value="1">open new window</option>
<option value="2">close window</option>
</select><br>
<input name="testinput" value="" type="text" style="width:100px;"/>
</form>
<a href="[removed]void(0)"
onclick="xajax_actionClose(xajax.getFormValues(\'' . $id . '\'))"
>submit formdata</a><br/>
</div>';
}
private function windowContentSubmit($data) {
// do something with data...
$content = print_r( $data, true );
return '
<div style="width:200px;height:200px;
background:#456789;color:#000000;border:1px solid #999999;padding:5px">
<a href="[removed]void(0)" onclick="xajax.closeWindow()">close</a><br/>
' . $content . '
</div>';
}
} // class
?>
I think the code is clear enough.
I wish this could help.
~epsi sayidina [: little gnubie :]