Hello, can someone show me how to change this into javascript to bubble element function. so I can use the published value to set dynamic margin for group focus targeting div inside of html element.
Well, it looks like it might be like the below, but don’t quote me on this!
Where are you getting it from anyway? Have you pulled out the console or something?
It doesn’t look like it’s complete as you’re missing the end < /script> tag.
$.fn.textWidth = function (text, font) {
if (!$.fn.textWidth.fakeEl) {
$.fn.textWidth.fakeEl = $('').hide().appendTo(document.body);
}
$.fn.textWidth.fakeEl.text(text || this.val() || this.text()).css('font', font || this.css('font'));
return $.fn.textWidth.fakeEl.width();
};
$('#inpt').on('input', function () {
$('#' + this.id + '-width').html($(this).textWidth() + 'px');
}).trigger('input');
I found it on stackoverflow. it does work (look at the app) it’s missing script tag because discourse think im trying to make code injection. There are much better ways to prevent that… oh well.
edit: I need to use bubble_fn_functionname to use the value elsewhere. right?
In your script, you need to insert a command with this syntax: “bubble_fn_suffix( value goes here );” in order to pass the value back to a JavascripttoBubble element. In order for this to work, you also have to have “Publish value” checked for the JavascripttoBubble element.
In your case, you have:
JavascripttoBubble Element A
bubble_fn_suffix: textWidth
Publish value?: checked