Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Add text style
-
- Posts: 92
- Joined: Mon May 14, 2018 3:26 pm
Re: Add text style
marc,
You'll need to do something like this in the Javascript section of the Form you are opening.
Steven
You'll need to do something like this in the Javascript section of the Form you are opening.
Code: Select all
$('#cus_name').css('font-weight', 900)
Steven
-
- Posts: 92
- Joined: Mon May 14, 2018 3:26 pm
Re: Add text style
Is it also possible to format different text elements? Bold the first word, the second underline etc.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Add text style
You can't do this inside a <textarea>, not one that's editable. It sounds like you're after a WYSIWYG editor, most of which use a <iframe> to do this.
E.g. https://alex-d.github.com/Trumbowyg
E.g. https://alex-d.github.com/Trumbowyg
-
- Posts: 92
- Joined: Mon May 14, 2018 3:26 pm
Re: Add text style
I followed the documentation to transform a nuBuilder textarea into a Trumbowyg WYSIWYG editor .
The editor is shown but saving/loading to the database doesn't work. Do you have any idea how to make this work?
Code: Select all
$('#textarea_editor').trumbowyg();
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Add text style
In short, I would create an additional div element and initialize the plugin on it. When your form loads, the content of the nuBuilder text area is assigned to the editor and when saving, the content is written back.
I may be able to provide more details a little later.
I may be able to provide more details a little later.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Add text style
Ok, here a more detailed instruction to impelement the trumbowyg WYSIWYG Editor in nuBuilder:
1. Import Files (JS, css). Add under Setup -> Header:
(change the path!)
<link href="libs/trumbowyg/ui/trumbowyg.min.css" rel="stylesheet">
<script src="libs/trumbowyg/trumbowyg.js"></script>
2. Create a new object of type html. The div is going to be transformed into a WYSIWYG editor as soon as your form loads (step 3)
Step 3: Add this code in your form (Custom Code -> JS):
1. Import Files (JS, css). Add under Setup -> Header:
(change the path!)
<link href="libs/trumbowyg/ui/trumbowyg.min.css" rel="stylesheet">
<script src="libs/trumbowyg/trumbowyg.js"></script>
2. Create a new object of type html. The div is going to be transformed into a WYSIWYG editor as soon as your form loads (step 3)
Code: Select all
<style>
li {
display: list-item;
}
</style>
<div id="htmlEditor1" placeholder="The text goes here" style="background:white">></div>
Code: Select all
if (nuFormType() == 'edit') {
// init the trumbowyg plugin
$("div[id^='htmlEditor']").trumbowyg({
btns: [
['viewHTML'],
['undo', 'redo'],
['formatting'],
['strong', 'em', 'del'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['unorderedList', 'orderedList'],
['horizontalRule'],
['removeformat'],
['fullscreen']
],
semantic: false,
resetCss: true,
removeformatPasted: false
});
// get the html code of the nuBuilder field and assign it to our html editor
var html = $('#nuBuilderEditor1').val();
$('#htmlEditor1').trumbowyg('html', html);
}
function nuBeforeSave() {
// get the html code of the html editor and assign it to our nuBuilder field
var html = $('#htmlEditor1').trumbowyg('html');
$('#nuBuilderEditor1').val(html).change();
return true;
}