Topic: Modal Window Issue

I am trying to use the modal window from  within a class.
I can make it work as a stand-alone script but when I put the code into a class I get an error:
ERROR: ExecuteCommand (#0, ):
Invalid response command: Command [{data}] is not a known command.

This seem to occur when  the addWindow method is called.
$objResponse->clsmodalWindow->addWindow( $this->windowContent('full', false),
                                'color'     =>  '#000000',
                                'opacity'   =>  20,
                                'bOverlay'  =>  true

If I put an alert in before this call, the alert pops up, and the  index goes up to 1
ERROR: ExecuteCommand (#1, ):

This tells me that xajax is working correctly, but seems to get stuck on this function
call. firebug reports no errors, and the debug window from xajax shows the response
for the modal window.

RECEIVED [status: 200, size: 873 bytes, time: 286ms]:
<?xml version="1.0" encoding="utf-8" ?>
<cmd color="#000000" opacity="20" bOverlay="1" cmd="mw:aw" plg="clsmodalWindow"><![CDATA[S<div style="width:400px;height:200px;background:#FFFFFF;color:#000000;border:1px solid #999999;padding:5px">
        <div style="border-bottom:1px solid #999999">
            <button type="button" onclick="xjxmW.closeWindow()">Close</button><br/>
        <h4>Kevs Modal Window</h4>
        <form id="c9823aab95751ded4ec4c7ad8c443103" 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;"/>
        <button onclick="xajax_mfl_action_close(xajax.getFormValues('c9823aab95751ded4ec4c7ad8c443103'))">submit formdata</button>

The function itself looks like this:

  public function mfl_duplicate_search($values)
                $objResponse = new xajaxResponse();
                $content = 'this is the search results';

                include_once TOP_DIR.'/xajax/xajax_core/';
                include_once TOP_DIR.'/xajax/xajax_core/';
                include_once TOP_DIR.'/xajax/xajax_plugins/response/modalWindow/';

                // $objResponse->alert('balh');
                $objResponse->clsmodalWindow->addWindow( $this->windowContent('full', false),
                                'color'     =>  '#000000',
                                'opacity'   =>  20,
                                'bOverlay'  =>  true
                return $objResponse;

Kind regards

Re: Modal Window Issue

Search a little through the clsmodalWindow class, I tried
$objResponse->plugin( 'clsmodalWindow', 'addWindow', $this->windowContent('full', false), '#000000', 20 );

but this just gives me

ERROR: No response processor is available to process the response from the server.
Content-Type: text/html.
Check for error messages from the server.

and in the response an error..
Notice: Undefined offset:  3 in /home/kevin/xajax/xajax_plugins/response/modalWindow/ on line <i>148</i>


Re: Modal Window Issue

And finally, I try this...

$objResponse->plugin( 'clsmodalWindow', 'addWindow', 'ssssssssssssssssssssssss', array('color'     =>  '#000000','opacity'   =>  20,'bOverlay'  =>  true) );

and I have come full circle..
ERROR: ExecuteCommand (#0, ):
Invalid response command: Command [{data}] is not a known command.

I will try to make a test case when I get home..


Re: Modal Window Issue

Hi Kevin,

i hnotice you use the latest version of mW.

Please don

Re: Modal Window Issue

I have tried the options, but still the same error, I have been able to reproduce the error here


Re: Modal Window Issue

I think you need to move the 3 require_once's to the constructor or to the start of the file so that the modalWindow plugin gets registered and the <SCRIPT> to include modalWindow.js gets generated. When I did this your code ran.

Looking back over old posts, this seems to be a perennial gotcha with plugins.

Re: Modal Window Issue

Yes, this works... sorta.

In my stand-alone instance, this works fine, but when I put the code into my application the error appears again.
Once again, I put in an alert, and the alert works, but, again, the same error.

You mentioned that the " <SCRIPT> to include modalWindow.js gets generated".
Does this mean the javascript is not being generated?

When I view the source, the javascript seems ok
<script type='text/javascript' charset='UTF-8'>
/* <![CDATA[ */
xajax_mfl_duplicate_search = function() { return xajax.request( { xjxfun: 'mfl_duplicate_search' }, { parameters: arguments } ); };
/* ]]> */

and the response is quite clear in the debug window, yet is immediately follow by the error message.

Any clue on where to look would be great.


Re: Modal Window Issue


This clue was in what dickdock said about the modal window javascript not being generated. I checked the source and the include was there, however.. the path was incorrect, and missing trailing slash from $xajax->getJavascript('/xajax');
The path then looked like this..
<script type='text/javascript' src='/xajaxxajax_plugins/response/modalWindow/modalWindow.js' charset='UTF-8'></script>

Note the xajaxxajax_plugins....

changing the call to
and the script then was correct and the function works.

Thanks for you time and effort guys.