Dynamically updating the view with Handlebars - handlebars.js

I'm working on an app using Express.js and Handlebars. I want to have a page where you can enter text into a search bar, and the view will update to display the results of your search. The backend part of this is already working - the data is being retrieved just fine - but I'm not sure how to best go about updating the view.
I'm using express-handlebars for this app, so the views are formatted as .handlebars files, and being sent to the client via the res.render method. I have seen examples of, for instance, using a button to fill out a Handlebars template, but these examples use a static HTML file with a template in a script tag; I don't know how to translate that to what I'm working with.

Related

Ajax call on Elementor WordPress plugin

I am currently developing a widget for elementor and i have already done the PHP render part as it renders the HTML part dynamically. Now, i want to do same for js render part as live rendering. I thought of Ajax call so that I can get data from it and place it on js render part. I tried to Ajax call inside _content_template() function but it load first instead of HTML while adding it to the post while PHP render is fine. How can i handle this. Please any help is appreciated.

Create a template page for html that can be used on every page

I would like to build the equivalent of a _layouts.cshtml page that I can use with every page in my web app. I don't want to use cshtml or razor though I want to use html. Is there a simple way to convert the _layouts page to standard html and then include it with the other pages in the app?
I have inherited an app that uses cshtml, with a _layouts page for menus and some content styling used on each page. I can duplicate the content on every page, but would prefer to have a generic solution for it. The client does not want to use cshtml pages. Any java library, such as AngularJS that would provide tools is ok for me to use. I'm not a front-end guy and this is a relatively low budget operation where I'm working for free. TIA.
i'm not familiar with .cshtml but on an html page you could use an iframe and update the contents of the iframe with different pages as needed.
you could also get external html and put it on the current page using jquery's get().
// get the contents of 'test.html' and put it into the 'result' element
// on the current page.
$.get("ajax/test.html", function(data) {
$(".result" ).html( data );
alert("Load was performed.");
});

How to scrape data in a page with jquery button click using HtmlAgility pack

I am trying to scrape data from a page with similar content(Shopping website) using HtmlAgility pack.
There is a button to load more items designed of tag. On click it loads more items on same page.
If it is designed using tag then I will get the next items using the href attribute URL in tag and also I will be loading new page for the new next items, So no problem.
But here no new URL and items loaded on same page.
So is there any way to get this functionality implemented? How to trigger that load more button to get more items?
HtmlAgilityPack is an html parser alone, it knows only to parse a static html document. what you want may be accomplished using selenium web driver.
Another possibility is - if the number of item load actions is so that you can complete the loading manually - do so and save the resulting html locally, and only afterwards use HtmlAgiliyPack to parse the static html you stored locally (instead of parsing the http response).
Share the link of the site you are talking about so I can add some code snippets to exemplify.

Meteor: Exporting rendered template for offline use

I have an online tool for users to build and preview slideshow presentations (uploading images, editing text).
Would there be a way to "export" the content of a rendered slideshow for offline use? This would mean the user could view the presentation locally in a browser using only static files.
Use
var myRenderedHTML = Blaze.toHTMLWithData(templateYouWantToCache, dataUsedToRenderTemplate);
Then use something like the Filesaver.js library to force download of that content as an HTML file. (as in the last demo on this page)

XPM / UI : Creating new pages based on Page Type with copied components

I relatively simple question regarding XPM this time. It's about creating Page Type which editors could use to base their new website page on. When defining a Page Type, you can use an exisiting page to enable this as an example page, including its components. You can copy these components to enable editors to edit these freely without tampering with existing pages using these components as well.
On the SDL Live content docs they explain the following:
Change the setting from Include this Component Presentation to
Include a Component Presentation that contains a copy of this
Component. If you use this Component in multiple Component
Presentations on this Page, then saving the Page causes all of those
Component Presentations to have the setting you configured last for
any of those Component Presentations. A number of new controls appear.
This means that whenever an editor clicks 'new page' within XPM, this page type is available and the components that are defined inside it are copied with user-specific prefixes. You can define this inside the page defined as a Page Type itself, by clicking on the component presentations tab, then clicking on a component and selecting Page Type settings. note the following:
As you can see, the copy of the content is being created in 050 - Web - Global, which is, in our blueprint, the wrong publication. However, in the popup you cannot select the correct content location, only the one where the page type is residing.
I've tested this, also with the UI -specific blueprint context settings, where you should define where content and pages are created. However, when creating a new page, the components are copied inside 050 - web - global; the wrong publication. As we're moving to a training, I'd imagine that dynamically created components like this might clog the CMS with content in the wrong location, making it unusable for other publications. Is there a reason for this behaviour, and if so, a way to make this work properly?
If you set the BluePrint Context for Components to the Publication where you want them to be created, it should work as you expect.

Resources