Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
ecommerce-ui
Commits
56c2b3a7
Commit
56c2b3a7
authored
Jul 25, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renderjs: fixed handling of loading same page in JQM
parent
fbc0ea18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
13 deletions
+39
-13
js/app.js
js/app.js
+39
-13
No files found.
js/app.js
View file @
56c2b3a7
...
...
@@ -143,8 +143,9 @@ define([
// @method initializeRenderJs
//
priv
.
initializeRenderJs
=
function
()
{
// TODO: remove if possible
// TODO: try to call "create" earlier (FOUC on first time load)
var
setFalse
=
false
;
// TODO: try to live without all bindings... in renderjs 2
priv
.
doc
.
on
(
'
pagebeforeshow
'
,
'
div.ui-page
'
,
function
()
{
var
page
=
$
(
this
);
// need to call this every time a page is shown...
...
...
@@ -152,30 +153,55 @@ define([
RenderJs
.
bindReady
(
function
()
{
var
gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
page
.
attr
(
'
id
'
));
if
(
gadget
.
isEnhanced
()
===
false
)
{
page
.
trigger
(
"
create
"
);
gadget
.
setEnhanced
(
true
);
}
});
})
.
on
(
'
pageremove
'
,
'
div.ui-page
'
,
function
()
{
.
on
(
'
pagebeforehide
'
,
'
div.ui-page
'
,
function
(
e
,
data
)
{
// pagebeforehide triggers before remove and data includes the new
// page being loaded. This means we can override clearing the gadgetIndex
// in case we are going to a page that has already been loaded. Instead
// we setReady to false.
var
page
=
$
(
this
),
pageId
=
page
.
attr
(
'
id
'
),
nextPageId
=
data
.
nextPage
.
attr
(
'
id
'
),
pageGadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
pageId
);
if
(
nextPageId
===
pageId
)
{
// renderJs will try to parse the page before pageremove fires, so
// if we don't set all gadgets on this page to false, renderJs does
// nothing...
if
(
page
.
attr
(
"
data-gadget
"
)
!==
undefined
)
{
pageGadget
.
setReady
(
false
);
pageGadget
.
setEnhanced
(
false
);
}
// also, set all gadgets on this page to false
setFalse
=
true
;
}
})
.
on
(
'
pageremove
'
,
'
div.ui-page
'
,
function
(
e
,
data
)
{
var
page
=
$
(
this
),
pageId
=
page
.
attr
(
'
id
'
),
pageGadget
;
// remove gadgets when removing pages,
// but not if we are doing a same page transition...
page
.
find
(
"
div[data-gadget]
"
).
each
(
function
(
i
,
el
)
{
var
gadget
=
$
(
el
);
if
(
gadget
.
is
(
'
.main-interactor
'
)
===
false
&&
!
setFalse
)
{
RenderJs
.
GadgetIndex
.
getGadgetById
(
gadget
.
attr
(
'
id
'
)).
remove
();
}
});
// if the page is a gadget itself, it needs to be reset here
if
(
page
.
attr
(
"
data-gadget
"
)
!==
undefined
)
{
pageGadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
page
.
attr
(
'
id
'
)
);
if
(
page
.
attr
(
"
data-gadget
"
)
!==
undefined
&&
!
setFalse
)
{
pageGadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
page
Id
);
pageGadget
.
setReady
(
false
);
RenderJs
.
GadgetIndex
.
unregisterGadget
(
pageGadget
);
}
// remove gadgets when removing pages
page
.
find
(
"
div[data-gadget]
"
).
each
(
function
(
i
,
el
)
{
var
regularGadget
=
$
(
el
);
if
(
regularGadget
.
is
(
'
.main-interactor
'
)
===
false
)
{
RenderJs
.
GadgetIndex
.
getGadgetById
(
regularGadget
.
attr
(
'
id
'
)).
remove
();
}
});
setFalse
=
false
;
})
};
...
...
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