The interaction between closures in JavaScript?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
5 views
There is a circuit:

(function () { // do something })() (function () { // do another thing }) ()



How would you set up the interaction between objects in these circuits?


Actually, the issue occurs when using jQuery in large projects... that is, for example, the dialog box in jQuery UI. But this is a special case of the General problem.


Usually I have it looks like this:
<div id="dialog"> <p>something</p> </div> <button id="show_dialog_btn">Show Dialog</button> the <script> jQuery(function ($) { $("#dialog").dialog({ a lot of parameters well, just the darkness of any settings and different colbecki, buttons: { OK: function () { // something to give birth.... } } }); $("#show_dialog_btn").click(function () { $("#dialog").dialog('open'); }); }); </script>



The dialog in this case, actually consists of NTML markup and Java script code. For simplicity, we omit TSSS. Now to create the same window on a different page, you need to either copy or... And here is where the problems start... If the parameters window depend on any parameters in this circuit, Suppose it by pressing the OK button should be called "local" for circuit function. How to be?
by | 5 views

2 Answers

0 like 0 dislike
You will help data, bind and triggerHandler. Well, my article :)
by
0 like 0 dislike
The simplest option:
\r
var common = { param1: 'value1', param2: 'value2', param3: 'value3', } 
by

Related questions

0 like 0 dislike
7 answers
0 like 0 dislike
1 answer
0 like 0 dislike
6 answers
0 like 0 dislike
1 answer
asked Apr 15, 2019 by Astafiev_Andrey
110,608 questions
257,186 answers
0 comments
27,881 users