May anyone helpe me on how to add a text inside a multiline input? I.e, when i click a button add a text inside a multiline input in current position in text. The way bubble works all the initial content of multiline is changed.
HI @juancosta900 sorry, I am not sure I understand the question?
Hi @StevenM. Just looking for a way to add a text inside existing multiline text. ALL Bubbleâs funccionality is to add a new content , for example, change the input data, but i canât find a way. Example of what i want:
Input A: Current Text Current Text Current TextâŚ
Result When click a Button add New text
Input A: Current Text (New Text) Current Text Current TextâŚ
The New Text must depend on the Text cursor position.
Have you tried auto-binding the thing?
Thereâs no such direct workflow.What you can do is
- Create a small group (say group âXâ), set its type to text and hide it
- set the initial content of the multiline input to be the âgroup Xâs textâ
- now you can display whatever you want initially as also the group Xâs text
- When button is clicked -> take the data from multiline input, modify it as u need -> display the result in group X -> reset multiline input
Thanks, but It seems doesnât work.
What i need is to add a preset text inside the multiline input text like the gif below
Do you need the text to be formatted like in your gif?
If yes i donât think you can do that because the multiline input in Bubble is an html textarea and you canât style individual text in a textarea.
If you donât need to style the added text then i might have some idea.
Will try it and get back to you if it works.
Thanks friend. The style is not important. I wait Your solution
Ok so here is the idea.
Youâre going to use copy and paste actions to achieve this.
For the copying, you can use, the Air Copy to Clipboard plugin.
Unfortunately the plugin currently doesnât support paste from clipboard so i was hoping i could update the plugin with a paste action but it seems itâs not that simple.
But the idea was that when the user clicks on the text to be inserted, you will copy that text, then give focus to the input and do a paste action to paste the text in the current cursor position.
The challenge will be how to implement the paste action. It seems due to browser security it may not be easy to pull it off
Thanks. But I was using Copy to ClipBoard but it was not practit for my users and still has some bugs. I used the mention workflow with @, but It does not work in Rich Text input.
Thanks @gaurav . But I was using Copy to ClipBoard but it was not practit for my users and still has some bugs. I used the mention workflow with @, but It does not work in Rich Text input. Stilo waiting any solution.
Any Idea. @NigelG @vincent56 @fayewatson
I canât think of any Bubble native way of doing it, so will need a bit of HTML/JS ?
Its a simple functionality that Bubble should add and have. @emmanuel
I suspect it is easy enough with a little Javascript.
function insertAtCaret(areaId, text) {
var txtarea = document.getElementById(areaId);
if (!txtarea) { return; }
var scrollPos = txtarea.scrollTop;
var strPos = 0;
var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ?
"ff" : (document.selection ? "ie" : false ) );
if (br == "ie") {
txtarea.focus();
var range = document.selection.createRange();
range.moveStart ('character', -txtarea.value.length);
strPos = range.text.length;
} else if (br == "ff") {
strPos = txtarea.selectionStart;
}
var front = (txtarea.value).substring(0, strPos);
var back = (txtarea.value).substring(strPos, txtarea.value.length);
txtarea.value = front + text + back;
strPos = strPos + text.length;
if (br == "ie") {
txtarea.focus();
var ieRange = document.selection.createRange();
ieRange.moveStart ('character', -txtarea.value.length);
ieRange.moveStart ('character', strPos);
ieRange.moveEnd ('character', 0);
ieRange.select();
} else if (br == "ff") {
txtarea.selectionStart = strPos;
txtarea.selectionEnd = strPos;
txtarea.focus();
}
txtarea.scrollTop = scrollPos;
}
insertAtCaret('myField', "foo");
The following code works in Bubble:
Just add this code inside HTML Script:
jQuery.fn.extend({
insertAtCaret: function(myValue){
return this.each(function(i) {
if (document.selection) {
//For browsers like Internet Explorer
this.focus();
sel = document.selection.createRange();
sel.text = myValue;
this.focus();
}
else if (this.selectionStart || this.selectionStart == â0â) {
//For browsers like Firefox and Webkit based
var startPos = this.selectionStart;
var endPos = this.selectionEnd;
var scrollTop = this.scrollTop;
this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length);
this.focus();
this.selectionStart = startPos + myValue.length;
this.selectionEnd = startPos + myValue.length;
this.scrollTop = scrollTop;
} else {
this.value += myValue;
this.focus();
}
})
}
});
$(â#testâ).click(function() {
$(â#textareaâ).insertAtCaret(âtextâ);
});
And than add a button id called âtestâ and a text input id called âtextareaâ
This is how works in bubble:
Looks good
Do you mind if I add this to BuildingOnBubble ?
OK, @NigelG.
I add this in ShowCase. See there.
This topic was automatically closed after 70 days. New replies are no longer allowed.