Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Ivan Tyagov
renderjs
Commits
8d5df8ca
Commit
8d5df8ca
authored
Oct 02, 2012
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a shorthand way to bind to Gadgets' ready event.
Use for this internally root dom element.
parent
4c1b743d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
renderjs.js
renderjs.js
+17
-8
No files found.
renderjs.js
View file @
8d5df8ca
...
@@ -149,6 +149,13 @@ var RenderJs = (function () {
...
@@ -149,6 +149,13 @@ var RenderJs = (function () {
is_ready
=
value
;
is_ready
=
value
;
},
},
bindReady
:
function
(
ready_function
)
{
/*
* Bind a function on ready gadget loading.
*/
$
(
"
body
"
).
one
(
"
ready
"
,
ready_function
);
},
checkAndTriggerReady
:
function
()
{
checkAndTriggerReady
:
function
()
{
/*
/*
* Trigger "ready" event only if all gadgets were marked as "ready"
* Trigger "ready" event only if all gadgets were marked as "ready"
...
@@ -157,8 +164,11 @@ var RenderJs = (function () {
...
@@ -157,8 +164,11 @@ var RenderJs = (function () {
is_gadget_list_loaded
=
RenderJs
.
GadgetIndex
.
isGadgetListLoaded
();
is_gadget_list_loaded
=
RenderJs
.
GadgetIndex
.
isGadgetListLoaded
();
if
(
is_gadget_list_loaded
)
{
if
(
is_gadget_list_loaded
)
{
if
(
!
RenderJs
.
isReady
())
{
if
(
!
RenderJs
.
isReady
())
{
// backwards compatability with already written code
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
RenderJs
.
GadgetIndex
.
getRootGadget
().
getDom
().
trigger
(
"
ready
"
);
trigger
(
"
ready
"
);
// trigger ready on root body element
$
(
"
body
"
).
trigger
(
"
ready
"
);
RenderJs
.
setReady
(
true
);
RenderJs
.
setReady
(
true
);
}
}
}
}
...
@@ -555,14 +565,13 @@ $(document).ready(function () {
...
@@ -555,14 +565,13 @@ $(document).ready(function () {
// Be careful, right now we can be in this case because
// Be careful, right now we can be in this case because
// asynchronous gadget loading is not finished
// asynchronous gadget loading is not finished
if
(
root_gadget
!==
undefined
)
{
if
(
root_gadget
!==
undefined
)
{
root_gadget
.
getDom
().
bind
(
"
ready
"
,
RenderJs
.
bindReady
(
function
()
{
function
()
{
// examine all Intaction Gadgets and bind accordingly
// examine all Intaction Gadgets and bind accordingly
$
(
"
div[data-gadget-connection]
"
).
each
(
function
(
index
,
element
)
{
$
(
"
div[data-gadget-connection]
"
).
each
(
function
(
index
,
element
)
{
RenderJs
.
InteractionGadget
.
bind
(
$
(
element
));
RenderJs
.
InteractionGadget
.
bind
(
$
(
element
));
})
})
}
});
);
}
}
}
}
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment