EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: debarcar on September 26, 2015, 07:19:17 AM



Title: callback between windows, help for sample code
Post by: debarcar on September 26, 2015, 07:19:17 AM
Hi All,

I have trouble in coding such a case:

Window A has a button. When the button click, system open Window B and pass a Window A method/function to Window B. When Window B close, it pass data to the method/function Window A past.

Any help or Suggestion? Regards!



Title: Re: callback between windows, help for sample code
Post by: Hoffiric on September 28, 2015, 04:58:24 AM
I don't quite understand your issue but seeing as nobody even tries to help you here's my two cents:

It makes no sense to me having to pass a method from a window to another. "Windows" are only DOM objects with extended functionality and methods can exist outside of them, so I don't understand why you would "pass a Window A method to Window B". To me it should look like this:

Code:
    <script type="text/javascript">
    <!--
      function DoSomething(param)
      {
        $("#data").text(param.val()); // "Cross window" action
      }
    -->
    </script>
  </head>
  <body>
    <div class="easyui-panel" style="position: relative; width: 100%; height: 650px; overflow: auto;">
      <div id="win_a" class="easyui-window" data-options="title:'Window A',inline:true,closable:false" style="width: 500px; height: 200px; padding: 10px">
        <div id="data">&nbsp;</div>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#win_b').window('open')">Edit</a>
      </div>
      <div id="win_b" class="easyui-window" data-options="title:'Window B',inline:true,closable:false,closed:true" style="width: 500px; height: 200px; padding: 10px">
        <input class="easyui-textbox" type="text" name="data_in" id="data_in" data-options="required:true"></input>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="DoSomething($('#data_in')); $('#win_b').window('close')">Save</a>
      </div>
    </div>

the script holds the function that is being run when Window B is closed. So the workflow is

  • Window A is open by default
  • Press Button on Window A
  • Button opens Window B
  • Enter data in Window B
  • Press Button on Window B
  • Invoke (global) DoSomething() with the data field from Window B as parameter
  • Close Window B
  • DoSomething has updated a div on Window A to contain the value from the data field from Window B

What you defined in DoSomething will be executed when pressing the Button on Window B (the same code is usable for an OnClose event, however I haven't found any on EasyUI).

Again, I have no idea if this is even remotely close to what you were looking for. Please specify your problem a bit more so you can get more detailed help for your problem.


Title: Re: callback between windows, help for sample code
Post by: debarcar on September 28, 2015, 08:43:49 AM
Thanks Hoffiric.

Perhaps I use some extjs thought to do this. You are right, for easyui, we have a new way.

Regards!