EasyUI Forum
April 29, 2024, 02:57:08 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: load php page from server and refresh the content of window (does not work)  (Read 3991 times)
paule32
Newbie
*
Posts: 12


View Profile Email
« on: December 28, 2021, 11:18:32 AM »

Hello and very nice holidays,

I have the following php (html) code: (test.php) https://dpaste.com/AREZGVRVV

the file is loaded at a jquery div dblclick event handler, and I place the
data into a easyui-window via:

$('#win_1').window({href:'/test.php'});
$('#win_1').window('refresh');

All works fine in "one" stage - means: when I open the file twice, I get error messages
into the console.log, and the web application stops.

Plain raw html stuff works fine, but I have some javascript's, and css styles within the
test.php file.
And these files, I would be load, too, to work with the function's, and the content.

I don't want to load all js, and css stuff at load time, because I sit on a bigger project,
so load time is very important.

My Question is now: how can I "unload" scripts, to open window/panel more than one times
so, that the contents will be handled correctly by the browser.

It would be great, if You can give some tips, and a little demo.

Thank You in advice
paule32
Logged
paule32
Newbie
*
Posts: 12


View Profile Email
« Reply #1 on: December 28, 2021, 04:09:28 PM »

Hello,

I could locate the line:

...
var opts = $('win_' + name).window('options');
console.log(opts.closed);
...

its the first line of this text above.
The Error Message occurs, when I try to open the same window (id, class, content, ...)

Named Error-Message is in FireFox:

Uncaught TypeError: $(...).window is not a function
...
...
...

can you help ?
thanks
Logged
paule32
Newbie
*
Posts: 12


View Profile Email
« Reply #2 on: December 28, 2021, 05:42:27 PM »

Hello,

this is a snippet, extracted from my sources, to demonstrate a bug... ?
Bellow, You can see the file test.php:
on one click on a button/icon, the window will open, and work well.
on second click on the same button/icon, i get:

TypeError $(...).window is not a function

in file dummy.js:
if have a helper function, that should help, to prevent load the same stuff:
function page_loaded_init() { /* dummy */ }

/* this is test.php: */
function add_icon(func)
{
   $('#icon").dblclick(function(){
      if (typeof window["page_loaded_init"] == 'undefined') {
      func();
      $.parser.parse();
      }
      else {
      $("#win_Mathematik").window('refresh');
      $.parser.parse();
      }
   });
}

$(document).ready(function()
{
   add_icon(function() {
      let data = ""
      + "<div id='win_Mathematik' class='easyui-window' "
      + "data-options='title:\"Mathematik\",inline:true,"
      + "href:\"/pub/desk/apps/edumath/test.php\","
      + "onClose:function(){window[\"page_loaded_init\"] = undefined;page_loaded_init=undefined;return;}'  "
      + "style='width:325px;height:140px;padding:5px;'>"
      + "blub"
      + "</div>";
      $("#WindowsDesktop")
      .append(data);
   });
}

Is it a bug, or do I something wrong?
Thanks for feedback

paule32
Logged
paule32
Newbie
*
Posts: 12


View Profile Email
« Reply #3 on: December 31, 2021, 05:08:39 AM »

Hello,
I did coded a complicated "reload", and it works fine with one html file, and one window.
When I need more windows, I can place them in the "load" file, since JS is global with
"var" declarations.
It works not 100 percent perfectly, but it does his job.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!