I am trying to implement a list where I should pick an item from it, I am trying to use a ListPicker:
<StackLayout verticalAlignment="top">
<ListPicker id="inquiryType" items="{{ inquiryTypeItems }}" />
</StackLayout>
Is there any way to make the ListPicker modal, and show it by clicking on a readonly TextField?
I am using Javascript on Nativescript.
Thanks!
Put ListPicker to modal dialog wont be good idea as u need to create platform dependend creating and processing that picker
So first approach would be dialogs actions and on tap open dialog with options,
array of options, only strings
http://docs.nativescript.org/cookbook/ui/dialogs#action
Example (taken from link above if it happens it wont work for u and little rewrited for your case):
var options = {
title: "Inquiry Type",
message: "Choose inquiry type",
cancelButtonText: "Cancel",
actions: inquiryTypeItems
};
dialogs.action(options).then((result) => {
console.log(result);
});
or as second approach,
U can set ListPicker as hidden on load of page after tapping on something(definitely not TextField, as u can get problem with showing keyboard, either Label or Button) show ListPicker with animation or visibility property and on change or maybe on Done button which would be together with ListPicker it would let people to choose from list of items :)
If u have other data together with other properties better for second approach but if u have some simple array of strings u can use first one
I am not sure how you would do this in plain NativeScript, however, if you are using Angular2, then you can use an angular modal and then nest the nativescript ListPicker inside that.
So the README of the Angular2 Modal Project describes creating ui agnostic modals very thoroughly. Then in its content, you would do something like:
<div class="container-fluid custom-modal-container">
<div class="row custom-modal-header">
<div class="col-sm-12">
<h1>A Custom modal design</h1>
</div>
</div>
<div class="row" [ngClass]="{'myclass' : shouldUseMyClass}">
<div class="col-xs-12">
<div class="jumbotron">
<h1>Pick Something:</h1>
<ListPicker id="inquiryType" items="{{ inquiryTypeItems }}" />
</div>
</div>
</div>
</div>`
Here shows how the components might fit together.
You can see the issue which track supporting this in NativeScript.
Related
I'm using Jetstream blade components in my project, including x-jet-dialog-modal and x-jet-input. The modal window is used to add or edit records and works fine. The inputs are bound to a model "person" using the "wire:" syntax, and everything goes as expected.
Now I want to use the same modal window to show the record fields in a read-only manner, when pressing a "view" button. My idea is to make the inputs read only and hide the "save" button dynamically, using a public property of the Livewire controller (component).
So, in Livewire component I have a default value:
public $disableEdition = false;
And in the blade file:
<div class="mt-2">
<x-jet-label for="name" value="{{ __('Name') }}" />
<x-jet-input id="name" type="text" class="form-control" wire:model.defer="person.name" {{ $this->disableEdition ? 'readonly' : '' }}/>
<x-jet-input-error for="person.name" class="mt-2" />
</div>
I expected the input field to appear with attribute "readonly" (and of course non-editable and formatted with corresponding Bootstrap styles), but the browser inspector reveals that no attribute was added to the input.
Maybe you can help me with a solution or even a better approach to accomplish my goal.
Best regards.
I want to use a list element for drop-down select menu but it implemented everywhere with model. I use Spring I want the user to select items from a static list.
There are some use like
<form:select path="...." items=$(......)>
but it needs a model for items as I understood. Also I don't want to post anything I just need the value of the select menu and I will do everything with JS. How can I achieve this?
My List element:
private static String[] lang = {"en","fr","tr","es","de"};
I tried to use List like that but didn't work. I mean every form elements gone.
<form:form commandName="TranslateService">
<div class="form-group col-sm-6">
<label class="control-label" for="first-name">Target Languages<span class="required">*</span>
</label>
<div>
<form:select path="lang" items="${lang}"></form:select>
</div>
</div>
</form:form>
it's a hard way to solve your question. instead of this you can create a model for form.
My issue is similar to the one here: paper-menu-button's dropdown (paper-menu) not overlaying other iron-list items, but no adequate solution is proposed there.
The problem is that I have a <paper-dropdown-menu>, which opens up correctly inside the <iron-list> item it is in, but goes underneath the following <iron-list> items:
I have a simple <paper-dropdown-menu> like this:
<paper-dropdown-menu-light class="custom" label="Languages" no-label-float>
<paper-listbox class="dropdown-content" selected="1">
<paper-item>Spanish</paper-item>
<paper-item>English</paper-item>
<paper-item>French</paper-item>
<paper-item>Sinhala</paper-item>
</paper-listbox>
</paper-dropdown-menu-light>
which is inserted into another element with an <iron-list> (which loads a JSON file with <iron-ajax>):
<iron-list id="list" items="[[bookList.books]]" as="item">
<template>
<div>
<div class$="[[getClassForItem(item, selected)]]" tabindex$="[[tabIndex]]" style="z-index: 1;">
<div class="avatar">[[item.id]]</div>
<div class="pad">
<div class="primary">[[item.titleen]]</div>
<div class="shortText">[[item.slug]]</div>
<div class="longText">[[item.blurb]]</div>
<div class="languagedrop">
<language-drop></language-drop>
</div>
</div>
</div>
</div>
</template>
</iron-list>
I tried setting the z-index for each <iron-list> item to 1, but that did not work. I tried working with <iron-overlay>, but I did not manage to get that done. I'm very new to Polymer, so if anybody has a solution or workaround that would be great.
That's because iron-list is using transform: translate3d for each list item.
The workaround that I have found is working is to add z-indexto the current list item (<div class="item"></div>) on which you have the dropdown expanded, or to all items from top to bottom in descending order, programatically.
I have been stuck in a problem since couple of days.
I am trying to get the UIKIT Modal on the top of another UIKIT modal.
I have an EditModal and SubEditModal as follows:
<div id="modalEdit" class="uk-modal">
<div class="uk-modal-dialog uk-animation-scale-up">
<div class="modalTitle"><h1>Edit</h1></div>
<a class="uk-modal-close uk-close"></a>
</div>
</div>
<div id="modalSubEdit" class="uk-modal">
<div class="uk-modal-dialog uk-animation-scale-up">
<div class="modalTitle"><h1>Edit</h1></div>
<a class="uk-modal-close uk-close"></a>
</div>
</div>
I have address listing in modalEdit. When the user clicks on edit in one of address, I use the modalSubEdit to display the edit form. This should be displayed on the top of modalEdit. I wrote the following jquery:
$.get(url, function (data) {
var container = $('#modalEdit .uk-modal-dialog');
var targetDiv = $('#modalSubEdit .uk-modal-dialog');
targetDiv.empty();
targetDiv.append(data);
container.add(targetDiv);
});
The problem is as soon as the modalSubEdit is displayed, modalEdit closes itself. When I dig deep into it, I found that, as soon as modalSubEdit is displayed, the display property of modalEdit is set to none.
I would be very much thankful if someone could come up with some suggestions or solutions.
Also thanks to the viewers for their time.
My page in working perfectly with postback. My problem is that it's kind of anoying every ingredients or subtitles that people submit, it reloads the entire page. So, I though that it could be a good way to learn a little bit of ajax... I've read a lot of article, and I got confused. Some people are using Ajax.Beginform and others are using the $.ajax from jQuery inside an event of jQuery (submit for example). I've read that the second approach is better but I don't know if it's possible with the way my form is done.
Here is the important part of my View. To summarize, I have a list of subtitle, and each of the subtitle can contain a list of ingredients. One of the form can submit ingredients, and the other can submit subtitle. The first one can appear multiple time (in each of the subtitle).
<div id="Ingredients">
<h2>Ingrédients</h2>
#foreach (RecettesMaison.Models.Subtitle sub in Model.Subtitles)
{
<h4>#Html.DisplayFor(modelItem => sub.Name)</h4>
<ul id="ing#nSubtitle">
#foreach (RecettesMaison.Models.Ingredient ing in sub.Ingredients)
{
<li>#Html.DisplayFor(modelItem => ing.QuantityAndName)</li>
}
</ul>
using (Html.BeginForm("AddIngredient", "Recipe", new { subname = sub.Name }, FormMethod.Post))
{
#Html.HiddenFor(model => model.IDRecipe)
<a name="IngredientSection" ></a>
<input class="field required span6 text-box single-line" id="nameingredient" name="nameingredient" />
<input type="submit" class="btn btn-success" value="Ajouter un ingrédient" />
}
nSubtitle++;
}
#using (Html.BeginForm("AddSubtitle", "Recipe", FormMethod.Post))
{
#Html.HiddenFor(model => model.IDRecipe)
<a name="SubtitleSection" ></a>
<input class="field required span6 text-box single-line" name="Name" />
<input type="submit" class="btn btn-success" value="Ajouter une catégorie d'ingrédient" />
}
</div>
My first approach was that if a submit is successful, I would "refresh" the two foreach with the new data. But the approach I've seen on must tutorial is to use a partial view and refresh only the partial view inside of a div. But in my case, my Html.BeginForm would be inside the partial view so I don't think it would work. I also think about just appending html at the end of my list but it will only work of the ingredient. So the best way would be to refresh both for each
So, my general question
How can I do that? :)
Thanks!
Ajax.BeginForm vs .ajax()
Both accomplish the same thing. Ajax.BeginForm will hide the javascript details so .ajax() will probably give you a better foundation in understanding the pattern especially if you ever need to work outside of MS technologies.
AJAX with Partial Views
It's entirely possible and there are many examples on the web even here on SO. The general idea is you're just replacing a div with partial view content retrieved via AJAX.
If the div is static, then your jquery selectors are quite simple.
If the div is dynamically generated, then you'll need to do some DOM traversing to find the target div.
Without seeing your attempts it is hard to give you specific help. I suggest you start with a simple example with a single partial view and form and update it using AJAX. Then you can move to a more complex situation with multiple forms once you understand the mechanics.