Hi All,
i am new to sightly.i understand that javascript USE class will be an server side programming. is there any way we can call an function written in javascript use file from sightly template? below is code which i am trying to but the call is not getting executed onclick. let me know how to achieve this kind of scenario
HTML:
<div data-sly-use.model="logic.js">
<button id="clear-completed" onclick="${model.addItemAction}"> Click
</button></div>
logic.js
use('/apps/todo/components/utils/filters.js', function (filters){
'use strict';
var model = filters;
function addItemAction() {
log.info("11111111111111111111111111111111111111111111111");
}
model.addItemAction = addItemAction();
return model;
});
Solved! Go to Solution.
Views
Replies
Total Likes
Sightly is *only* server-side. So the onclick() here will never work.
I don't fully agree with Scott's comment on Java/OSGi. Both work well, and depends on your experience and other design considerations.
Views
Replies
Total Likes
For server side execution of app logic with Sightly - you can use Java and OSGi (modified based on Feike comments)
The Java class extends com.adobe.cq.sightly.WCMUse.
Using Java and Sightly - see this article:
https://helpx.adobe.com/experience-manager/using/creating-sightly-component.html
Views
Replies
Total Likes
Sightly is *only* server-side. So the onclick() here will never work.
I don't fully agree with Scott's comment on Java/OSGi. Both work well, and depends on your experience and other design considerations.
Views
Replies
Total Likes
As @feike mentioned you will not be able to JS like code as sightly is server side.
It would be great if you can share your use case may be community can tell better approach
Views
Replies
Total Likes
Thanks a lot for the replies. Now i understood why it wont work which i tried.
I have an scenario. can you please let me know how we can implement
1. There is an HTML form in sightly
2. once submit data has to be pushed to Servlet (as we cant invoke function in javascript use class i have wriiten an ajax call in another js file)
3. we need to send the inputs to service which gives an additional details (calling the OSGI service in servlet and getting additional data)
4. the additional details has to be passed to another sighlty page and display the same in UI (how to do this from servlet ????)
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies