Skip to content

Instantly share code, notes, and snippets.

@LaurensRietveld
Last active September 14, 2018 02:44
Show Gist options
  • Save LaurensRietveld/7d8beca5dbeb6b909b6f to your computer and use it in GitHub Desktop.
Save LaurensRietveld/7d8beca5dbeb6b909b6f to your computer and use it in GitHub Desktop.
Combining #YASQE and #YASR

A simple example on how to combine YASQE and YASR. Any SPARQL result received via YASQE are passed on to YASR. YASR, uses any prefixes defined in YASQE to prettify the SPARQL results.

var yasqe = YASQE(document.getElementById("yasqe"), {
sparql: {
showQueryButton: true
}
});
var yasr = YASR(document.getElementById("yasr"), {
//this way, the URLs in the results are prettified using the defined prefixes in the query
getUsedPrefixes: yasqe.getPrefixesFromQuery
});
//link both together
yasqe.options.sparql.callbacks.complete = yasr.setResponse;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Glueing YASQE and YASR</title>
<link href='http://cdn.jsdelivr.net/g/[email protected](yasqe.min.css),[email protected](yasr.min.css)' rel='stylesheet' type='text/css'/>
</head>
<body>
<div id="yasqe"></div>
<div id="yasr"></div>
<script src='http://cdn.jsdelivr.net/yasr/2.4/yasr.bundled.min.js'></script>
<script src='http://cdn.jsdelivr.net/yasqe/2.2/yasqe.bundled.min.js'></script>
<script src="glue.js"></script>
</body>
@semanticfire
Copy link

When I copy this example I have to reload the page to get my query results to show
I use the YASQE-1.4 and YASR-1.2

In the debugger I see that the query gets performed on the backend

@LaurensRietveld
Copy link
Author

Ah, I missed this comment, sorry about that. Could you try the latest version of YASR (1.2.1)? There was an issue related to the new DataTables programming interface, which made the results table unable to update on new query results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment