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
d944d3f3
Commit
d944d3f3
authored
Sep 26, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form submit handler via AJAX (replace with JIO later)
parent
87528cef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
4 deletions
+45
-4
js/erp5_loader.js
js/erp5_loader.js
+45
-4
No files found.
js/erp5_loader.js
View file @
d944d3f3
...
...
@@ -5788,14 +5788,12 @@
));
//
enhance
//
NOTE: update layout and set .... (hey Romain: bindings)
$
(
document
)
.
enhanceWithin
()
.
off
(
"
.init
"
)
// NOTE: set a global click listener for every link that
// wants to open the global popup. This will just store
// a reference on the popup for which content to load
// global popup handler & content shuffle/caching
.
on
(
"
click
"
,
"
.
"
+
handler
,
function
(
e
)
{
var
link
=
e
.
target
,
reference
=
link
.
getAttribute
(
"
data-reference
"
),
...
...
@@ -5811,6 +5809,49 @@
if
(
rebuild
)
{
pop
.
setAttribute
(
"
data-rebuild
"
,
"
true
"
);
}
})
// global form submit and client validation
// TODO: change as pleased
.
on
(
"
click
"
,
"
.action_submit
"
,
function
(
e
)
{
var
valid
,
form
=
document
.
getElementById
(
e
.
target
.
getAttribute
(
"
data-form
"
)),
target
=
e
.
target
.
href
,
id
=
form
.
id
,
pointer
=
"
response:
"
+
id
,
proceed
=
function
(
data
,
target
)
{
// changePage with fragment_cache pointer
$
.
mobile
.
changePage
(
target
,
{
"
transition
"
:
"
slide
"
,
"
data
"
:
data
});
};
// stop
e
.
preventDefault
();
// validate
// TODO testForClass not working
if
(
$
(
form
).
hasClass
(
"
validate
"
))
{
valid
=
$
(
form
).
triggerHandler
(
"
submitForm
"
);
}
else
{
valid
=
$
(
form
).
serialize
();
}
// fetch and proceed
if
(
valid
!==
false
)
{
$
.
ajax
({
"
type
"
:
"
POST
"
,
"
url
"
:
"
foo.php
"
,
"
data
"
:
valid
}).
done
(
function
(
data
)
{
// overwrite cache
// NOTE: FAKE data until working
priv
.
fragment_cache
[
id
]
=
priv
.
getFakeRecords
[
"
payment
"
];
proceed
(
pointer
,
target
);
}).
fail
(
function
(
jqXHR
)
{
// fake it
priv
.
fragment_cache
[
id
]
=
priv
.
getFakeRecords
[
"
payment
"
];
proceed
(
pointer
,
target
);
});
}
});
}
});
...
...
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