Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Editing fragment causes running of javascript on every keyup
Editing experience is currently a little limited because existing javascript in the fragment is run on event change. Could there be a run button?
We were generating a preview on every keystore to allow seeing the actual result without the need of pressing any button. It's true that we are executing JavaScript everytime you change fragment's content, but with a less-blocking JavaScript this shouldn't be so annoying. Do you feel like we should disable realtime preview?
Yes!Have a run button instead.
I agree with Lee Jordan.
Hey Lee, Christoph,Thanks once again for your feedback.We would prefer to avoid having a run button if possible. Would you mind sharing some real fragments that showcase how the current behavior is annoying?Also, we have been working on a feature to provide previews while working on a desktop environment of your framework of choice. It would be great if you could take a master snapshot and give us your feedback. It will most probably be included in SP1 and later GA2.
Well, we haven't really started created fragments for now, so I have no real world experience so far. And we will probably never use the online editor anyway, so I am not very invested into this.
But I generally dislike automatically running javascript when I am developing. For us javascript is usually just this:
initComponent(divId);
Such a component can be anything, often it is e.g. a carousel. We also load data from the backend quite often. Every keystroke would do backend calls. I am not sure, if that's a good idea.
But I generally dislike automatically running javascript when I am developing. For us javascript is usually just this:
initComponent(divId);
Such a component can be anything, often it is e.g. a carousel. We also load data from the backend quite often. Every keystroke would do backend calls. I am not sure, if that's a good idea.
I completely agree with you Christoph, if there are ajax calls going on having that run on every key stroke could cause extra HTTP requests and could bomb some API calls for spamming. Also if I make a syntax error it could bomb the application right? I mean not just the fragment but could cause DXP to bomb out. I admit even I can create infinite loops, having the code just execute could cause instability.
We haven't looked at fragments in detail in terms of how we could use it, perhaps our first use case would be to live edit web content (which should be done in at least basic web content displays without fragments anyway).
We haven't looked at fragments in detail in terms of how we could use it, perhaps our first use case would be to live edit web content (which should be done in at least basic web content displays without fragments anyway).
The problem really is the javascript runs upon editing the HTML or CSS. I know this one is really basic, but shows how annoying it could be. I think the CSS "auto running" is really neat, the HTML auto running could get a little sketchy though if it's running on incomplete syntax.
How about run / autorun in like a button drop down. Use the button to run code and the dropdown to turn autorun on/off? If that's still no go, could it only auto run the type of code you're currently editing? That way then the javascript isn't run when editing the HTML.
How about run / autorun in like a button drop down. Use the button to run code and the dropdown to turn autorun on/off? If that's still no go, could it only auto run the type of code you're currently editing? That way then the javascript isn't run when editing the HTML.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™