how to not execute a scriptlet code in a tab when using jquery ui tab plugin - jquery-ui-tabs

I just came across jquery ui tabs plugin.
Its a very nice implementation but what If current code is in place.
<div id="tabs">
<ul>
<li>tab1 </li>
<li>tab2</li>
</ul>
<div id="tabs-1"><%System.out.println("test1");%></div>
<div id="tabs-2"><%System.out.println("test2");%></div>
</div>
in this case, when the page initially loads, tab1 is the default tab. However, both the sys out statements are executed initially. It does not matter what the default tab is. Ideally first sys out should execute when tab1 is selected and second when tab2 is selected.
Is there any way to avoid this? Or the only way is to have different pages for different tabs?

the scriptlet will execute because it is not restrained by javascript. If you have content in tabs-1 and tabs-2 that you do not want to execute until unless the tab is clicked then you should use the 'ajax' feature of this plugin. The demo site shows how to do this.

Related

Prestashop 1.7.1 - Top banner which hook shall be used?

Following this question I have created a new banner.
Now I want to insert a hook, but I am wondering which hook shall be used to display it on top of every page (as a promotional banner).
Thanks
Assuming you're using the classic theme, you can use the displayBanner hook. If you look at header.tpl you can find the following block:
{block name='header_banner'}
<div class="header-banner">
{hook h='displayBanner'}
</div>
{/block}
which should be displayed on top of every page

Aurelia eating my Bookmarks

I am working on a legacy application that is being rewritten using Aurelia, the application has a bunch of static html in a tblHelp that needs to be displayed. I am using innerhtml.bind on a div in my view to databind the stored static HTML into the view. Each record is essentially a document complete with a full table of contents that links to other divs within the document (Bookmarks).
Something like:
<div id="toc">
<h1>Table of Contents</h1>
<ul>
<li>Section 1<li>
<li>Section 2<li>
</ul>
</div>
<div id="section1">
<h2>Section 1</h2>
<p>Paragraph Text...</p>
<p>Back to Table of Contents</p>
</div>
<div id="section2">
<h2>Section 2</h2>
<p>Paragraph Text...</p>
<p>Back to Table of Contents</p>
</div>
When I display the resulting page in my Aurelia view and click on the links, rather than moving to the proper Div on the current page, it seems to be attempting to route to an unknown route and ends up returning to the home page (that is my unknown route behavior). How do I make the Aurelia Router know that I am just moving around the same page and do not require it to route to another page?
I think you need to change your <div id= to <a id= which is the correct syntax for anchors. Hopefully Aurelia will recognize them as legitimate anchors when formatted correctly.
Also, since an anchor tag shouldn't wrap the whole content, you'll just open and close it at the top of the div. You can even leave the divs there but should not duplicate the id.
Update:
That being said, I created a GistRun that actually demonstrates that Aurelia should be able to handle the <div id= anchor targets. So, I'm not exactly sure why you're having problems.
Maybe this GistRun or the more standard <a id= approach will help you.

django-autocomplete-light how to copy multi select fields

I'm using django-autocomplete-light with django 1.8.
I want to be able to copy the selected contents from one autocomplete field into another which requires overriding javascript code.
I tried duplicating the html content inside the autocomplete tool into another one in the browser debugger which looked good but when I click the save button in the admin page, it ignores my copied value.
Any ideas?
It works if you use an empty form for #form_template as such:
<div class = 'table' id="form_template" style="display:none">
{{ formset.empty_form }}
</div>
<div class = 'table'>
<table>
<!-- don't use #form_template in your actual form -->
From github issue

How to open multiple pages in the same app?

I know that Aurelia is a framework for an SPA but I need to open multiple pages at the same time inside the browser.
I want to host each page (view/viewmodel) within a draggable div and have more than one open at the same time. They will be selected by the User from a menu.
I have looked at viewPorts but cannot see how they will help in this problem.
Is there another way to do this?
Yes, there is a way to do this.
You say pages, but basically they are components. Every component has a HTML (view) and JS (view-model) file. They can be included as custom-elements.
So if you want multiple possible components on one page, all you need to do is create one component that has a placeholder for those views.
Probably, you would want something looking like this:
running Gist example
<template>
<require from="./page1"></require>
<require from="./page2"></require>
<page1></page1>
<hr>
<page2></page2>
</template>
You can create loop for all elements you want to display, if you need multiple instances of the same page, and put a repeat.for on the elements:
HTML:
<template>
<require from="./page1"></require>
<require from="./page2"></require>
<page1 repeat.for="i of page1instances"></page1>
<hr>
<page2 repeat.for="i of page2instances"></page2>
</template>
JS:
export class App {
const page1Instances = 4;
}
Making them drag&droppable works like every other element, there are many solutions for that to be found. Just make the <page1> and <page2> draggable.

easy durandal please wait while loading spinner

Is there an easy durandal way to clear the view and put a loading or please wait... on the screen so the user gets some feedback to know that it is working until the ajax content loads?
Right now when I click on a something that navigates to a child route and that child route loads a module that has to do a lot of stuff in activate(), it does not switch the nav or clear the screen or give any feedback to the user that it is working and I see them clicking many times over and over and getting frustrated, then just about when they want to give up, the page loads in fine.
I would like to make this default functionality for my app and not have to do something special in every module or on every page, is that possible?
Thanks.
Have you tried to use router.isNavigating? Original Durandal template contains a spinner like this:
<div class="loader pull-right" data-bind="css: { active: router.isNavigating }">
<i class="icon-spinner icon-2x icon-spin"></i>
</div>
A large percentage of the time, what you're looking for can be obtained very simply via:
<div data-bind="compose:ActiveVm">
<div class="text-center" style="margin : 75px">
<i class="fa fa-spinner fa-spin"></i>
</div>
</div>
The inner div can be any arbitrary markup which will display while the viewmodel is going through activation.
Note that this currently only displays the placeholder content the first time this dom section is composed. If you have a section of your application which is being updated via an observable viewmodel + compose approach, you could use the approach here:
Durandal: Showing a 'LOADING...' during composition
For anyone visiting from the future, this issue might be worth checking out in case native support for this is desired:
https://github.com/BlueSpire/Durandal/issues/414