Can I cache an empty form template as a second page in browser?
can I cache an empty form template as a second page in browser cache so that when you click "create event" button on first page it immediately opens empty form template without having a need to download the template from the server as it's cached.
Just like CREATE EVENT button in Google calendar; which let's you to switch between calendar and new e开发者_Python百科vent form template.
Well, you can either use Javascript for building the new page from scratch when the respective action is invoked (probably quite tedious) or you can use an invisible section (e.g., a separate <div>
) of the HTML page (style = display: none
) and make it visible by changing its class to a visible style and making the original page invisible (change its style to display: none
).
One way to accomplish this would be to load your second view into a hidden container. You can hide it with a simple CSS display property toggle, like this:
<div id="mySecondView" style="display: none;">
<!-- content of second view here -->
</div>
And on button click you can do this to unhide it:
With jQuery:
$('#mySecondView').show();
or
$('#mySecondView').fadeIn();
Without jQuery:
document.getElementById('mySecondView').style.display = '';
Of course you'll have to position the second view via CSS as you want it, otherwise it'll just pop up in some weird place that won't make sense.
精彩评论