How to set default selected menuItem in TVML? - tvos

Is there a way to set a menuItem which's order is not the first to be first view ?
jus like Youtube, they using MenubarTemplate and the first menuItem is search, but always shows the second one in first run.
I can setSelectedItem in code, but you still see the focus was on first one in a very short time, so can I set a default page which is not first of menuItem in TVML ?

Use attribute autoHighlight="true" (https://developer.apple.com/library/tvos/documentation/LanguagesUtilities/Conceptual/ATV_Template_Guide/TVJSAttributes.html#//apple_ref/doc/uid/TP40015064-CH42-SW1). It's working in several templates, one of them being the Menu/Navigationbar - but some others seem to be buggy.

Related

Html selector using Regex

So there is a page that I want to perform some action on with puppeteer. The problem is that there is a text area in which I want to type in something however the id of it is :
id="pin-draft-title-13a10e18-5a1e-49b9-893c-c5e028dc63e1"
As you might have guess for some reason only pin-draft-title remains the same but the whole number part changes for every refresh so puppeteer can't find it. I tried deleting the id and copying the selector itself the whoe #_Root div>div etc but that seems to be changing after sometime as well. So the main question is is there any way i can just select it using the pin-draft-title part and no matter what numbers follow it still selects it ?
You can use [id^=pin-draft-title-]
In case of javascript, if you want to select all the elements whos ID starts with a specified string or pattern, in your case "pin-draft-title", then consider using the following syntax.
document.querySelectorAll('[id^="pin-draft-title"]');

Nesting multiple mat-radio-button not working as expected

I have mat-radio-group that has more mat-radio-group within it. I have created a stackblitz here
https://stackblitz.com/edit/angular-mdgy7x?file=app/radio-overview-example.ts
In the example when the page loads, I want to show 'ledger' radio option selected along with value1 below it selected as default. If I update the radio button to 'available', I need to select the 'value 1' below 'available' radio.
The code works fine for all cases, except the first case wherein I have to show default selection.
Can some one point out where I am going wrong?
For some reason, nested radio groups / buttons need a second update cycle in order to correctly update the default state. One way to achieve this, is to add a 0ms timeout in one of the lifecycle hooks before calling onRadioFilterChanged() with the default value. The earliest hook I found this to work in is ngOnInit(). You'll also need to set all checked properties to false so that a state change can actually happen, triggering the update.
So, adding
ngOnInit() {
setTimeout(_=> this.onRadioFilterChanged('L'), 0);
}
and setting checked: false also on the first checkboxes in each group will do the trick, as demonstrated in this updated stackblitz:
https://stackblitz.com/edit/angular-mdgy7x-dcijkt?file=app%2Fradio-overview-example.ts
Despite the 0ms timeout, you'll notice a slight delay on page load, but other than that and the kind-of-hack-ish feel to it, it works - and I haven't been able to get it to work in any other way so far.
First, add the call to ngOnInit:
ngOnInit(){
this.onRadioFilterChanged("L");
}
and create a variable to keep the value of ledger and available like for radios.
Then use that value in onRadioFilterChanged.
Another thing that is not working is when you select one of the sub-radiobuttons.
I achieved what I want using the following code. What I basically did is created separate radio buttons for parent and child and each of them has an ngModel associated with it. I then manipulate ngModel based on user interaction.
Following is the stackblitz,
https://stackblitz.com/edit/angular-mdgy7x?file=app/radio-overview-example.ts

How to disable buttons on the selected value of the other in AngularJs

I have two buttons - Company Email and Non Company Email.
If i select the first , ng-click="flag='Y'" and the second one renders the flag value as 'N'
So now I am trying to disable them when they are selected so user is not allowed to click on the second time, the second click is creating some UI issues which I want to avoid here.
But the ng-disabled is not working at all as expected, it disables from the outlook but we can still click the button and it behaves strangely.
Pleas help-
Code block is added in comments
This seems like a simple enough issue where you would disabled the buttons using a scope variable set once a button is clicked.
<button ng-disabled="flag=='Y'" ng-click="doCompany()">Company Email</button>
Here is an example

GxtRtl Html and HtmlContainer flips input html content

I use Gxt-2.2.5-Rtl (http://code.google.com/p/gxt-rtl/) and try to show html content through HtmlContainer's setUrl() method. But unfortunately the result is flipped version of my expected output. For example suppose our input html contains a table which starts columns from right to left as id, name, description. So what we get is a table that their column starts from expected order BUT FROM LEFT TO RIGHT!
I used Gxt's Html and Gwt's HTML and HtmlPanel classes, but this problem doesn't solve.
In addition I should say when I use TabItem or ContentPanel's setUrl() method this problem disappears. But I prefer to don't use that method and because:
1- Just last loaded iFrame is visible at a time. This means that navigating through other preloaded tab items displays a blank page.
2- Poor control over loaded page through GWT, like catching click events and etc.
Expected output:
http://www.freeimagehosting.net/yow6l
Wrong output:
http://www.freeimagehosting.net/8opdt
I changed the titles to English for better communicating! :)
Thanks!

It is possible to add to Unordered List during runtime

I have a simple HTML page with an Unordered list. Is it possible to have an input field where you could add more to the list and it would be saved after you submitted it. What I would like to add would be the content inside of an <li> tag as well as the <li> tags themselves.
Thanks,
Here is a jsfiddle with a demo of what I think you want to achieve: http://jsfiddle.net/mvJNq/25/
Note that I can not answer as to how you should do this on the server, as that depends on how your serverside code, database etc is set up. However, if all you want is to display it as HTML and not have it saved as the user navigates away, you won't need the Submit button at all - then you just need the "Add" functionality.
Yes, it is possible - no, it will not be pretty. Here is what you would do:
create your base form with any default list items/inputs
use jQuery/JavaScript to bind an event handler to a button that you click when you want to add another item (alternatively, you could skip this step and just have another item appear by default)
on your event (be it checking that all input boxes have user-entered text, or the click event in step two) add another list item using jQuery.append(...)
ensure that you have a hidden input field to be used as a "counter" to keep track of the total number of list items and increment the value of this counter each time you add a new list item (note: you may need to use the ParseInt() method, depending on how you design the code for this field)
the page that is receiving the form's inputs should first read the hidden field so that it knows how many items to add, and then you should loop through the items (for or while loop) to add them correctly
Note: I don't know what Server-Side language you are using to handle receiving the form so step 5 is a fairly generic and universally viable option
Sure, it's possible.
The complexity of this comes in when you want to "save" the items. If the user leaves the page and comes back later will that data be available? If so, you will need a database like mySQL or similar. The li tags can be stored as well, but why?
If you just need that information available in that session you can store in a JavaScript variable and have it loop through the variable and spit them out as <li>'s
If you did want to use an add button instead of submit:
$('#addButton').click(function(){
var savedContent = $('#input').val();
}
To create + insert the <li>you can use javascript to create the element and append it to the ul. If you have more than one ul change the index:
var content = document.createElement('li');
content.innerText = savedContent;
document.getElementsByTagName('ul')[0].appendChild(content);