Hi,
I'll provide an example how I change standard radiobuttons to jQuery ui-choose (
https://wangxing218.github.io/ui-choose/test/demo.html)
In my case I acheive this such way:
1. Put on form the table, that will contain the controls I wich to change, put on it the controls and set style attribute display: none
2. Put on form "HTML" element and set it's content as
Code: Select all
<div><select class="ui-choose" id="my-coose"><option value="First">First</option><option value="Second">Second</option></select></div>
3. Work on it with javascript (actually examples are in typescript):
3.1. first of all, I have to load the script containing component and css styles for it. I store the files in Site Assets library and use $.getScript to get it:
Code: Select all
function prepareScripts(...scriptNames: string[]): Promise<any> {
let promisesArray = new Array<Promise<any>>();
scriptNames.forEach(scriptName => {
let promise = new Promise((resolve, reject) => {
$.getScript(scriptName, () => {
resolve();
});
});
promisesArray.push(promise);
});
return Promise.all(promisesArray);
}
Code: Select all
function prepareCss(...fileNames: string[]): Promise<any> {
let promisesArray = new Array<Promise<any>>();
fileNames.forEach(fileName => {
let promise = new Promise<any>((resolve, reject) => {
$.get(fileName, () => {
$("<link>", { rel: "stylesheet", type: "text/css", href: fileName }).appendTo("head");
resolve();
})
});
promisesArray.push(promise);
});
return Promise.all(promisesArray);
}
3.2. When scripts are ready, I set the html to be jQuery UI component:
Code: Select all
Promise.all(prepareScripts("path-to-js"), prepareCss("path-to-css"))
.then(() => {
$("#my-coose").uiChoose(options)
});
3.3. A also need to link the form field events to newly created UI element. In Options object there is change event, on that you could subscribe your callback, that contain such piece of code:
Code: Select all
change: (placementType: tPlacementType) => {
fd.field("eventPlacementType").value(placementType);
setVisibilityPlacementType(placementType);
}