Does anyone know how to cache html between routes in polymer. I am not referring to offline caching here.I am a novice in Polymer, any help is greatly appreciated.
For example, If while I am in template A I make some operations and show few data on the UI as a result of those operations, then I go to template B, if I come to template A again the entire UI is refreshed and the previous data is not shown on UI. How do I stop this from happening.
In angular for instance we set cache:true in routes to retain the page contents. I am looking for something in similar to that.
Related
I am relatively new to ServiceNow, and I am building some UI pages where I basically do not need any of the SN structure except for Glide Ajax (I need to get data from a Script Include).
The problem is that when I select "Direct" the Glide Ajax functions are not available any more in the client script.
Does anybody know if this is possible to achieve? I searched everywhere without success.
Thanks a lot!
If you check "Direct", it omits all ServiceNow specific JavaScript and CSS. "GlideAjax" is ServiceNow specific JavaScript.
If the data that you are pulling back from the Script Include is static (meaning that you can pull it when the UI page is loaded) then you can probably do it inside an "evaluate" block in the HTML section of the UI page. You could have your Script Include return a JSON object as a string and store it in a variable. Then you could have your client JavaScript parse that variable. I am not a Jelly expert, so I would be curious to know if it works.
I'm working on a Wordpress site which displays posts through a JSON api and AngularJS. I render all post thumbnails on a page and when one is clicked the post is rendered in an overlay on the same page. The post url becomes something like mysite.com/#!/post-name.
Here's the development page http://givakt.kund.griffel.se/blogg-jobb/
Since everything is fetched by AJAX calls none of this info is available to search engines. I have tried to figure out a good approach to make it indexable but it's all very new ground to me.
Would it be possible to get content from or redirect the search engine to a php-rendered (wordpress) page, say like mysite.com/post-name, while thinking it's getting the correct content at mysite.com/#!/post-name. Is it even allowed or even frowned upon? The actual content would of course be as identical as possible at both sources.
Not sure if this is legit approach however, or if it could even work. Is there any other easier or preferred approach that I'm missing?
BTW, I have read http://www.yearofmoo.com/2012/11/angularjs-and-seo.html and how to use PhantomJS and so on to provide indexable pages. So what I'm basically asking is if there's a way to utilize wordpress pages to serve the content instead.
I'm not exactly sure how to do it in terms of technicalities, but Google is usually not happy if you show one version of the page to search engines and something else to actually visitors. It's called cloaking. Just keep it in mind.
Hi I'm pretty new to web applications, and I want to make a small form that search for an object and show the results there. I don't want to load the whole web page, probably change only one <div> tag.
Is there a way to do this without Javascript? (It's not mandatory that I don't. Just checking if I can)
I'm using Pyramid framework (and has been working with less than 2-3 days, so please be patient with your answers).
Please point me in the right direction, I feel like I don't even know what to search for.
(Didn't go anywhere with my pyramid XMLHTTPRequest google search).
Thanks a bunch.
No, that's what AJAX is, a Javascript technique. You cannot initiate a XMLHTTPRequest from your browser without it.
Just use jQuery to load a URL from you Pyramid server; have one route serve up a HTML snippet instead of a full page:
$('div#somediv').load('http://serveraddress/route/to/snippet')
and jQuery will request /route/to/snippet from your server, and place the result wholesale under <div id="somediv"></div>.
What you need is a Javascript library like jQuery to do the XMLHTTPRequest (popularly known as AJAX). See jQuery.post()
I'm working on a website that uses AJAX to retrieve data from the server and display it on the page. Django renders the initial page content using its template engine (so it will be indexed by search engines). When the user takes an action, jQuery fetches the new data via AJAX and the response is returned as JSON. I would like to have jQuery render this new content without violating the DRY Principle. Therefore I would like to use a templating engine that is "shared" between Django and jQuery. I've been running in circles trying to find the best solution but always seem to run into a road block.
Has this already been done? Here are the options I have thought of:
Use regular expressions to transform the Django template into correct jQuery template syntax, and render it in its raw form to the page. jQuery will then pick it up and use it to render the new data.
Extend the jQuery template engine to recognize the Django template syntax, again rendering the raw Django template to the page for jQuery to use.
Has this been successfully done before? Either way seems like a lot of work for anything but the simplest of Django templates because of the plethora of Django tags and filters that would need accounted for.
Your best bet is to pick a template language that has both Javascript and Python support, and use that everywhere.
As far as I know, Mustache is your best bet.
I haven't found a perfect solution since I asked this question, but for the sake of development time I resorted to sending back both JSON and HTML in the AJAX response. This way the django templates still perform the HTML generation, but javascript is still free to utilize the data without having to parse the HTML.
I am sending approximately twice the data over the network, but I'm going to live with it until my application grows to the point where a smaller response is beneficial. At that point I will probably look into something like Mustache as Rob mentioned.
I've got a cookie set up to store the user's theme preference, etc., but I've never used AJAX before, so I could use a little help.
I found this simple little AJAX tutorial, which is enough to get me started, but I'm not sure if I'd be better off having the server send pretty much the entire web page all over again, with the updated theme, or -- if it is possible -- having the server send a script that would modify the page, keeping the content intact, but changing the div, etc. properties in order to achieve the new look.
Thoughts? Comments? "You're doing it wrong, moron"?
Thanks in advance!
If changing theme means only change the classes of your divs and the elemtes of the structure of your page you must do it simply changing the class="" atribute of the html elemts involved. Ej: You can change postions, and floats, colors etc etc.. This would appen only in client without asking to the server again the page (0% traffic from server, nice!)
But, if changing theme means to get other html structure and hierarchy complety different: You dont have other way that ask to the server the page again with the new html...
Conclusion: Think about all those things, if you can get other theme only changin css you can/must use jquery to change the css properties. But, if not, you need to load the new html from the server...
I hope this help you
pd: sorry for my englisgh grammar if its not correct at all!