i have a question on what the object.visible property in titanium alloy actually means.
in the profile.js controller file of the app there is a check if the user is logged in (state = null) and depending on this either (a) a "not logged in" a text label message (id = not_logged_in_message) shows up or (b) the profile data is visible.
now when the user is logged in, the text label (or rather its content) does not show up but it seems that the xml label tag (marked in darkred rectangle) is still there pushing everything lower.
if (state === null) {
$.topBar.setTitle(L('Please login'));
$.profile.visible=false;
$.not_logged_in_message=true;
} else {
$.topBar.setTitle(L('Profile'));
$.profile.visible=true;
$.not_logged_in_message=false;
get_profile();
}
thx for any suggestion!
Check this out at the appcelerator forum:
http://developer.appcelerator.com/question/161936/vertical-layout-visible--false-but-controls-still-occupying-space
Visible means: its hidden from the view but not removed from the structure.
You could try the suggestions from the answer over there, like removing the label or alter the width and height.
Related
In an Nativescript application I need to implement a custom navigation scenario for Android when user click on material/soft back button.
For simplicity, starting with login-tabs template (https://github.com/ADjenkov/login-tabs-ng) and I want implement a navigation like Instagram, Facebook, WhatsApp, Pinterest, and many more ...
That's with the example of login-tabs template, when I navigate from the Players tab to the Teams tab and then I tap the back button I want to return to the Players tab (on the page I left in this tab).
Today as the navigation history of the Teams tab outlet is empty and the navigation history of the root outlet is empty, the application is closes. I wish it was close if I tap on the back button after returning to the Players tab and if navigation history of Players tab is empty.
I hope it's clear, tell me if it's not the case.
Is there a way to implement this behavior?
Finally I implemented a solution that's inspired by the response of #Manoj.
I listen to the activityBackPressed event and set args.cancel = true for prevent default behavior.
At each Tab change I save the Tab previously visited. Then at every activityBackPressed event I check if the current outlet can go back or not with this.routerExtension.canGoBack({ outlets: [this.tabVisibleName], relativeTo: this.activeRoute }).
If not I return to the previous tab programmatically if the list of tabs visited is not empty. If the list of tabs visited is empty I set args.cancel = false for exit the app.
If this.routerExtension.canGoBack({ outlets: [this.tabVisibleName], relativeTo: this.activeRoute }) return true I simply go back : this.routerExtension.back({ outlets: [this.tabVisibleName], relativeTo: this.activeRoute });
Note : you must remove listener when application is going to background, otherwise you will have several listeners (one by resume) :
application.on(application.exitEvent, (args) => {
if (args.android) {
application.android.off(application.AndroidApplication.activityBackPressedEvent);
}
});
Thanks for your help
You need to save selected Tab in your data.service and when user go back to tabs.component.html you can use the selectedIndex. You can skip to listen to activityBackPressed as well in that case.
in your tabs.component.html
<TabView (selectedIndexChanged)="onSelectedIndexChanged($event)" [(ngModel)]="selectedTabIndex" width="100%">
and in your tabs.component.ts
constructor(
private routerExtension: RouterExtensions,
private activeRoute: ActivatedRoute,
private _dataService: DataService ) {
this.selectedTabIndex = this._dataService.selectedTabIndex;
}
and
onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
const tabView = <TabView>args.object;
const selectedTabViewItem = tabView.items[args.newIndex];
this._dataService.selectedTabIndex = args.newIndex;
}
In my Nativescript app, the application starts with the login page. On iOS everything looks good, but on android, the username field is focused and the keyboard is showing. Is there a way to prevent this from happening?
So far I have tried:
Getting a reference of another element (a label) and calling lbl.focus() in the page's onLoaded event
getting a reference of the username textfield and calling txt.dismissSoftInput() and txt.android.clearFocus()
None of this worked. Is there another way to hide the keyboard when the page is loaded?
Thank you
I guess the username field is either textview or textfield. If so, try this on loaded callback:
var myTextview = page.getViewById("myTextView");
myTextView.dismissSoftInput();
So I ended up implementing a different solution. This may not be the best approach, but it serves its purpose in my case and I wanted to share it for those of you that face a similar scenario.
in page's loaded event I included this code:
if (page.android) {
var un = page.getViewById('username');
var p = page.getViewById('password');
un.android.setFocusable(false);
p.android.setFocusable(false);
setTimeout(function () {
un.android.setFocusableInTouchMode(true);
p.android.setFocusableInTouchMode(true);
}, 300);
}
The key here is the setTimeout function (Thanks Emil Oberg for pointing me to the right direction). As far as I understand, here is what is happening:
The page loads and we call setFocusable(false) on the only 2 text fields to prevent Android from setting the focus on them
Then we wait 300ms to allow Android to do its initialization
When the timeout executes, call setFocusableInTouchMode(true) to allow the fields to gain focus.
At this point the page is loaded without any fields to be in focus and with the keyboard hidden. If the user taps any of the fields the keyboard will appear and they can proceed to log in as usual.
As I mentioned, this may not be the best, or correct, approach, but works for me. Hope this can save someone the time to research the issue.
You want to clear the focus of the field in the loaded callback:
var searchBar = page.getViewById('my-search-bar-id');
if (searchBar.android) {
searchBar.android.clearFocus();
}
What about combining both tips above?
onClear(args) {
const searchBar = <SearchBar>args.object;
if (isAndroid && searchBar.android != undefined){//avoid random unpleasant error
setTimeout(() => { // the key here was this timeout
searchBar.android.clearFocus();
}, 1)
}
}
I'm using Laravel and I have a dropdown which fills its options from the database on load page and another text field.
Then on the submit I validate the text field to avoid empty entries, the validation is based on the request validator from Laravel. The validation is made correctly.
The problem is that when the validation is completed (it doesn't submit because i keep the text field empty) it returns to the page, but the dropdown remains selected with the last selection by the user, but in the back(sourcecode), its selected the original value that was loaded originally.
I want that the selectedIndex is the one original from the load page, not the last one selected. I tried with javascript but I had no luck change in it since it's already as the selectedIndex, but to the user, it still showing the other option. If I refresh manually it still showing the selected one incorrectly, I need to enter the URL manually so it shows correctly.
What could be a good approach to solve this "visual" issue?
Here is the controller code
public function update($user_id,GuardarBancoRequest $request)
{
$cuenta = user::whereId($user_id)->first();
$cuenta->nombrecompleto = Input::get('completo');
$temp = Input::get('tipo');
$cuenta->tipocuenta = Input::get('tipo');
$temp1 = Input::get('banco');
if ($temp == "1") {
$cuenta->cuentaclabe = Input::get('clabehidden');
$cuenta->cuentatarjeta = Input::get('cuentahidden');
} else {
$cuenta->cuentatarjeta = Input::get('cuentahidden');
$cuenta->cuentaclabe = Input::get('clabehidden');
}
if ( $temp1 == "10") {
$cuenta->otrobanco = Input::get('otro');
$cuenta->banco = "10";
} else {
$cuenta->banco = Input::get('banco');
$cuenta->save();
}
return Redirect::route('bancos.show',array(Auth::user()->id));
}
The dropdown that I'm referring is the [tipo] one
It's hard to presume without getting a chance to look at your code, but it sounds like when you do a redirect after validation you have something like
return redirect()->back()->withInput(); which causes fields to be prepopulated with the values entered earlier on the page. Remove withInput() portion in your controller if you have this.
Otherwise please mind posting your code in addition to your question, that would be helpful. (the controller part with the redirection and the view where you have the dropdown)
I want to change the visible state and enable state of a link button inside a data list when another button in the same data list is clicked.How can I do that?
Here is the code:
if (e.CommandName == "Save")
{
DataListItem item = (DataListItem)(((LinkButton)(e.CommandSource)).NamingContainer);
LinkButton lnk=(LinkButton)item.FindControl("LinkButton2");
lnk.Visible=false;
}
This code is not working
Hello I am a bit late in answering this but for Linkbutton to change its visible state by using display:none
lnk.Attributes.Add("style", "display:none");
I'm doing some Mac development in a WebView. I want to expand URLs that have been shortened by a url shortener, and display that expanded URL to the user. So, given a link whose src attribute is set to http://is.gd/xizMsr, when the user hovers over the link I want the title tooltip to display http://google.com
My link tag looks like this:
Here's a shortened link to google
And here's the relevant javascript, which will use XMLHttpRequest to fetch the expanded URL and then update the title
var myRequest;
var mousedOverElement;
var isLoading = false;
function myFunction(anObject) {
if (isLoading == false) {
isLoading = true;
mousedOverElement = anObject;
var link = anObject.getAttribute('href');
var encodedURL = encodeURI(link);
var url = 'http://is.gd/forward.php?format=simple&shorturl=' + encodedURL;
myRequest = new XMLHttpRequest();
myRequest.open("GET", url);
myRequest.onreadystatechange = onStateChange;
myRequest.send();
}
}
function onStateChange() {
if (myRequest.readyState==4) {
if (myRequest.status==200) {
mousedOverElement.setAttribute('title',myRequest.responseText);
}
isLoading = false;
}
}
The problem is, when I hover over the link, and then stop moving the cursor, the title attribute is set properly, but the tooltip is not shown. I have to move the mouse again to make the tooltip show up. I don't necessarily have to move the cursor off of the link and then back over it, but simply moving a few pixels while remaining hovered over the link will do the trick.
I know that the title is being set properly from a combination of using the Web Inspector and the Javascript debugger in Safari. In fact, pretty much as soon as I hover over the link, I see the Web Inspector's view of the DOM in the "elements" tab update with the new title. But, if I take my hand off of the mouse, the tooltip never shows.
My assumption here is that WebKit only shows a tooltip when the user is moving the mouse. Is there a way to sort of "wake up" webkit, even if the cursor is not moving? Or am I better off implementing this with some of my own DHTML-ish magic instead of relying on the title attribute?
What about an element (move it over the anchor) or a wrapper (positive z-index) with a transparent background which will (onmouseover):
first add the anchor's title (you will have to modify your function)
and then change its (negative for the covering element) z-index (effectively putting the anchor in the foreground)
This way the title will be readily available. If necessary you can add a setTimeout() between step 1 and 2.
Or you could simply use setAttributeNode to modify the title attribute value.
You said
"The problem is, when I hover over the
link, and then stop moving the cursor,
the title attribute is set properly,
but the tooltip is not shown."
Its likely that because the title did not exist when you started the mouse hover, it could not display any tooltip (there was nothing to display). So no tooltip will appear. When you move the mouse again, this time it does have a title attribute, so it can display a tooltip. Theres not much you can do about that, its just how the browser works.
Instead your could try using a jQuery tooltip: http://www.reynoldsftw.com/2009/03/10-excellent-tooltip-plugins-with-jquery/
With jQuery you should be able control it so that a tooltip appears as soon as the title is set.