Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
RecommenderXBlock
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
RecommenderXBlock
Commits
98543f2c
Commit
98543f2c
authored
Jun 03, 2014
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Example of AJAX
parent
7dd659ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
recommender/recommender.py
+5
-0
recommender/static/js/src/recommender.js
+15
-0
No files found.
recommender/recommender.py
View file @
98543f2c
...
@@ -72,6 +72,11 @@ class RecommenderXBlock(XBlock):
...
@@ -72,6 +72,11 @@ class RecommenderXBlock(XBlock):
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
return
data
.
decode
(
"utf8"
)
return
data
.
decode
(
"utf8"
)
@XBlock.json_handler
def
handle_upvote
(
slef
,
data
,
suffix
=
''
):
print
"Upvote clicked!"
return
{
"Success"
:
True
}
# TO-DO: change this view to display your data your own way.
# TO-DO: change this view to display your data your own way.
def
student_view
(
self
,
context
=
None
):
def
student_view
(
self
,
context
=
None
):
"""
"""
...
...
recommender/static/js/src/recommender.js
View file @
98543f2c
function
RecommenderXBlock
(
runtime
,
element
)
{
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'handle_upvote'
);
function
voted
(
result
)
{
console
.
log
(
"Voted"
);
}
$
(
'.recommender_vote_arrow_up'
,
element
).
click
(
function
(){
$
.
ajax
({
type
:
"POST"
,
url
:
handlerUrl
,
data
:
JSON
.
stringify
({}),
success
:
voted
});
});
}
\ No newline at end of file
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