How to Call a Parent Window Function from a Child Window of a Modal Dialog

Asked 1 years ago, Updated 1 years ago, 63 views

I'm building a site with cakePHP2+mysql+bootsrap3.

From the parent window, open a child window を as an input window and
If you don't have the necessary ID, start a child window 2 to generate it and register your ID
I am trying to return it to child window 1.

In that case, how can I return the value from child window 1 to child window 2?
I don't know.

I'm sorry to trouble you, but please let me know.
Thank you for your cooperation.

 ----------- Parent View ---------------
<divid="Modal1" class="modal fade"></div>
<divid="Modal2" class="modal fade"></div>

<script language="JavaScript">
$(function(){
  $('#Modal1') .html(data);
  $('#Modal1').modal('show');
});
</script>

-------------------------------------------------------
<script language="JavaScript">
$(function(){
  $('#Modal2') .html(data);
  $('#Modal2').modal('show');

  initialize();

  function hoge(test){
    alert("I want to do this";
    $("#test").val(test);
    initialize();
  }

  function initialize() {
    // Initial processing
  }
});
</script>

-------------------------------------------------------
<script language="JavaScript">
$(function(){
  // I want to run the function of child window の
  hoge(1);
});
</script>

jquery twitter-bootstrap

2022-09-30 19:16

2 Answers


without globalization I think it would be good to write within the same unknown function.


2022-09-30 19:16

Generally, JavaScript is a callback, and objective-c is a way to solve this problem (although callback and delivery are strictly different).


2022-09-30 19:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.