The widgets can be installed through our CDN or npm. Usage through the CDN will maintain backwards compatibility, while the npm library will use semantic versioning.
<script src="https://cdn.traitify.com/js/v2/traitify.js"></script>
<script>
Traitify.setHost('your host url');
Traitify.setPublicKey('your public key');
assessment = Traitify.ui.component();
assessment.assessmentID('an assessment id you have generated via a server side client');
assessment.target("#the-id-of-the-target-you-wish-to-render-to");
assessment.render();
</script>
npm i --save traitify-widgets
import traitify from "traitify-widgets";
assessment = traitify.ui.component();
assessment.assessmentID('an assessment id you have generated via a server side client');
assessment.target("#the-id-of-the-target-you-wish-to-render-to");
assessment.render();
Click here to view other classes available to import, such as the TraitifyClient
.
assessment.render("SlideDeck"); // Render just the SlideDeck in the target element
assessment.render("Results"); // Render just the Results in the target element
assessment.render("PersonalityTypes"); // Render just the Type/Dimensions in the target element
assessment.render("PersonalityTraits"); // Render just the Traits in the target element
assessment.render("PersonalityDetails"); // Render just the details in the target element
assessment.render("PersonalityBlend"); // Render just the Blend in the target element
assessment.render("Careers"); // Render all the career components
assessment.render("CareerFilter"); // Render the career filter
assessment.render("CareerResults"); // Render the career list
assessment.render("CareerModal"); // Render the career modal
// Add content to the career filter
Traitify.ui.on("CareerFilter.updated", function(context){
context.customContent.appendChild(document.createTextNode("I am custom content"));
});
// Add content to the career modal
Traitify.ui.on("CareerModal.updated", function(context){
if(!context.customContent){ return; }
context.customContent.appendChild(document.createTextNode("I am custom content"));
});
// Update parameters and re-request careers
Traitify.ui.trigger("Careers.mergeParams", this, {experienceLevels: [4, 5], page: 1});
This is useful if you want to get the career results server side and modify the data returned or just want to proxy through your own server.
Traitify.ui.options.careerOptions.path = "/my-career-endpoint";
Traitify.ui.options.careerOptions.experienceLevels = [4, 5];
Traitify.ui.options.careerOptions.perPage = 10;
assessment.render("Radar"); // Render just the Radar graph in the target element
assessment.render("PersonalityHeading"); // Render just the archetype in the target element
assessment.render("Guide"); // Given an assessmentID with results, render just the Interview in the target element
assessment.targets({
"SlideDeck": "#slide-deck",
"PersonalityTypes": "#personality-types",
"PersonalityTraits": "#personality-traits",
"Results": "#results",
"Careers": "#careers",
"Guide": "#guide",
});
assessment.render();
// Event handlers must be set before the render command, or they will not be called.
assessment.on("SlideDeck.Finished", function(){
console.log("SlideDeck.Finished");
});
assessment.on("SlideDeck.Initialized", function(){
console.log("SlideDeck.Initialized");
});
assessment.on("SlideDeck.IsReady", function(){
console.log("SlideDeck.IsReady");
});
assessment.on("SlideDeck.UpdateSlide", function(event, slideResponse){
console.log("SlideDeck.UpdateSlide");
console.log(slideResponse);
});
assessment.on("SlideDeck.BackSlide", function(){
console.log("SlideDeck.BackSlide");
});
assessment.on("SlideDeck.Fullscreen", function(event, isFullScreen){
console.log("SlideDeck.Fullscreen");
console.log(isFullScreen);
});
assessment.on("Results.Initialized", function(){
console.log("Results.Initialized");
});
assessment.on("PersonalityTypes.Initialized", function(){
console.log("PersonalityTypes.Initialized");
});
assessment.on("PersonalityTraits.Initialized", function(){
console.log("PersonalityTraits.Initialized");
});
// Set globally
Traitify.ui.setLocale("es-us");
or
// Set just for the instance of the widget
assessment.locale("nl-nl");
Here is a list of the available locales (en-us
is the default):
- Chinese -
zh-cn
- Creole -
ht-us
- Dutch -
nl-nl
- English (GB) -
en-gb
- English (United States) -
en-us
- French (Canadian) -
fr-ca
- French (France) -
fr-fr
- Japanese -
ja-jp
- Norwegian -
no-no
- Portuguese -
pt-br
- Spanish (United States) -
es-us
- Swedish -
sv-se
assessment.allowBack();
assessment.allowFullscreen();
* currently only the big-five
assessment has perspective content
assessment.perspective("firstPerson");
OR
assessment.perspective("thirdPerson");
We expose our JavaScript api client that you can use to make additional calls to our API from the client side. We make available get
, put
, and post
functions. These methods will use the api key and url you configured when you initialized the Traitify library. Here is an example that returns career matches for a career-deck
assessment. Further documentation on the API methods available can be found at https://app.traitify.com/developer/documentation.
<script src="https://cdn.traitify.com/js/v2/traitify.js"></script>
<script>
Traitify.setHost('your host url');
Traitify.setPublicKey('your public key');
var assessmentId = 'an assessment id you have generated via a server side client';
Traitify.get('/assessments/' + assessmentId + '/matches/careers').then(function(career_matches){
console.log(career_matches);
});
</script>
npm install
npm run dev
npm run build
- React: https://reactjs.org
- Webpack: https://webpack.github.io