ldb68 Posted September 6, 2016 Share Posted September 6, 2016 I can force unigui controls to sincronize content at server side when content is setted at client side? I think is a common problem with uniHtmlFrame and javascript. If I call a js function to update a unigui control accessing to the content with unigui property give a old value. In may case I get the content from a tinymce editor via js and copy it to a unimemo: UniSession.AddJS('MainForm.UniMemo1.setValue(tinyMCE.get("edt1").getContent());'); The memo conntain the text from frame. If I try to read the UniMemo1.text conntent I get the old value (before the js call). Se here for a sample http://forums.unigui.com/index.php?/topic/7149-tinymce-4x-get-content/ Quote Link to comment Share on other sites More sharing options...
md9projetos Posted September 6, 2016 Share Posted September 6, 2016 Javascript will never actualize the server,thats why i try to use Delphi all the time. For me the only reason to use JavaScript is if the component still don´t do what you want,or for things like local storage . At least don´t base your logic in the state of the components that you change by using client side code,the problem is when someone else is going to change your code. And as far as I know it is not possible to force this sincronization also. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 6, 2016 Share Posted September 6, 2016 I can force unigui controls to sincronize content at server side when content is setted at client side? Hi, Fast solution and it can be optimized. Try this: tinyMCE.init({ /*selector: '#edt1', */ plugins: [ 'advlist autolink lists link image charmap print preview anchor', 'searchreplace visualblocks code fullscreen', 'insertdatetime media table contextmenu paste code' ], toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image', content_css: [ '//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css', '//www.tinymce.com/css/codepen.min.css' ], mode: "exact", elements: "edt1", setup: function(ed) { ed.on('keyup', function(e) { MainForm.UniMemo1.setValue(ed.getContent()); }); ed.on('change', function(e) { MainForm.UniMemo1.setValue(ed.getContent()); }); } }); Best regards. Quote Link to comment Share on other sites More sharing options...
ldb68 Posted September 6, 2016 Author Share Posted September 6, 2016 Javascript will never actualize the server,thats why i try to use Delphi all the time. For me the only reason to use JavaScript is if the component still don´t do what you want,or for things like local storage . At least don´t base your logic in the state of the components that you change by using client side code,the problem is when someone else is going to change your code. And as far as I know it is not possible to force this sincronization also. Yes. In my case I'm using the tinymce editor (more advanced of unihtmleditor). To set and get the content we need JS at client side. Sincronization can be done by ajaxRequest (event to server side) but is non a "linear" solution. Quote Link to comment Share on other sites More sharing options...
ldb68 Posted September 6, 2016 Author Share Posted September 6, 2016 Hi, Fast solution and it can be optimized. Try this: tinyMCE.init({ /*selector: '#edt1', */ plugins: [ 'advlist autolink lists link image charmap print preview anchor', 'searchreplace visualblocks code fullscreen', 'insertdatetime media table contextmenu paste code' ], toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image', content_css: [ '//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css', '//www.tinymce.com/css/codepen.min.css' ], mode: "exact", elements: "edt1", setup: function(ed) { ed.on('keyup', function(e) { MainForm.UniMemo1.setValue(ed.getContent()); }); ed.on('change', function(e) { MainForm.UniMemo1.setValue(ed.getContent()); }); } }); Best regards. Thanks it works. For small text can be a solution. For large text I think there is too much overhead. I tried to add a new funtion in the script to be called from main but I can't get to works AferScript ..... function GetHtml() { MainForm.UniMemo1.setValue(tinyMCE.get('edt1').getContent()); return "" } From delphi code I have error (GetHtml() not defined ...) UniSession.AddJS('MainForm.UniMemo1.setValue(GetHtml())'); Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 7, 2016 Share Posted September 7, 2016 Hi, OK, for now can you try this ?!: 1. Use setRawValue instead of setValue tinyMCE.init({ /*selector: '#edt1', */ plugins: [ 'advlist autolink lists link image charmap print preview anchor', 'searchreplace visualblocks code fullscreen', 'insertdatetime media table contextmenu paste code' ], toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image', content_css: [ '//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css', '//www.tinymce.com/css/codepen.min.css' ], mode: "exact", elements: "edt1", setup: function(ed) { ed.on('keyup', function(e) { MainForm.UniMemo1.setRawValue(ed.getContent()); }); ed.on('change', function(e) { MainForm.UniMemo1.setRawValue(ed.getContent()); }); } }); 2. procedure TMainForm.UniButton1Click(Sender: TObject); begin ShowMessage(UniMemo1.Text); end; Best regards. Quote Link to comment Share on other sites More sharing options...
GRFS2000 Posted July 18, 2018 Share Posted July 18, 2018 I'm doing a similar procedure, I get an HTML via JavaScrit, it visually appears on the screen in uniMemo, but on the server side it says Memo is empty. I'm using uniGUI Extjs 6.5, has anything changed? how to do that on the server side I can capture the contents of Memo Quote Link to comment Share on other sites More sharing options...
GRFS2000 Posted July 20, 2018 Share Posted July 20, 2018 Is there anything new? I needed to put a Time and in his event the routine to save the data, only passed the information from the Client side to the Server. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.