Polymer CoreInput set custom validation message and reverse direction - polymer

First
It looks like it's possible to set custom validation rules, but I'm wondering if there is any way to customize the validation messages (I need them to be in Arabic).
Second
Is it possible to reverse the direction of paper-input floating label (place it at top right instead of top left).

First
paper-input exposes a error attribute you can use to declaratively set a custom message. If you want to use core-input directly, that element exposes a setCustomValidity(message) for setting it.
http://www.polymer-project.org/docs/elements/core-elements.html#core-input
Second
That would be a good feature request to file against paper-input. I was able to get something working using CSS overriding, but the internals of the API could change in the future.
http://jsbin.com/megafucuvapo/1/edit

Related

Find getElementById property in window.document

Summary: I wanted to know if there was a way to open console in chrome, type window, go to document and search for the getElementById method
Reason: I was searching around and found a lot of the CSS styles for an element(see picture 1 below) and was curious if methods like getElementById were displayed as well
What I tried:
1) I tried looking searching for the getElementById by control + f and searched for "get"
2) Tried seeing if I could get info from mdn: https://developer.mozilla.org/en-US/docs/Web/API/Document/Document
3) Tried reading the link pasted on mdn https://dom.spec.whatwg.org/#interface-nonelementparentnode
Still couldn't find it though :/
element css styles
window.document properties
If I understand you right (directly - how to find 'getElementById' property within global Window object) it is possible to do. You should write in the console Window, open document, then __proto__ (should be the last property of the document object), then __proto__ again, and now you can find getElementById method here. The reason is Window object quite difficult, and uses prototypes to keep all inherit properties and methods: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype
you can get all the elements with a defined id doing right click-> inspect element-> console
and then document.querySelectorAll('*[id]')
but based on picture two, you want to retrieve the class name that starts with "google_"
then do document.querySelectorAll('google_');
or can you please clarify the question? maybe I'm not getting it right
You need to console.dir(document.__proto__.__proto__) as it is in the overall prototype of the document

Can't set step property in input type number iside alert

I have an input type number inside an Ionic v4 alert, the problem is that I can't set step property since It's not recognised, is there any workaround or solution?
If you have advanced alert needs you might consider making a modal form instead.
The alert doesn't have many configuration options.
I don't see the value in trying to recreate a full modal tutorial here. This seems to cover it quite well.
But the high level overview is that instead of using an alert you create what is basically a new page, but it is loaded in on top of the existing page and you can pass data in and out of it.

Setting (Bound) Model Object Properties from View in EmberJS...Programmatically?

QQ: How can I update an object's property to match the innerHtml of an element in a view when a button is clicked?
I am working on building a content editing interface using EmberJS and the HTML5 contenteditable attribute (via the Hallo editor). This means that valueBinding doesn't do the trick, since we're dealing with the actual page HTML, not input/textarea value attributes. I've built a similar app in Backbone, which lacks dynamic bindings but allows you to set the model object as a property of the view.
What's the best way to get this working with EmberJS? Should I set a property on the view to the entire model? Do I need to create some sort of innerHtml binding and view helper, modeled on valueBinding?
I've set up a fiddle with an example of what I'm trying to do (with basic jQuery handling of the contentEditable attribute, instead of hallo):
http://jsfiddle.net/W6gsW/2/
Thanks!
http://jsfiddle.net/ud3323/nXCvq/
I did change a few things with how you defined the bindings in App.docView to make things cleaner. My solution does feel a litte hackish, but it works with 1 line of code per property.

What is the attribute AlwaysEnableSilent used for?

I was looking at the raw HTML rendered by a SharePoint (2010) list item edit page, and I noticed that an input field (rich text field) made use of an AlwaysEnableSilent attribute. i have checked online for an explanation of what the attribute does, but have not been able to get a answer. Does anyone know what this attribute does?
Thanks, MagicAndi
ASP.Net validators allow you to turn them on/off using client side scripting using ValidatorEnable, but whenever you turn the validator on that way the validation fires immediately. Sometimes you (SharePoint) may want to be able to control which validators are active using client side scripting, but without the validation firing when you turn it on (during load, before the users have had the possiblity to fill out the fields).
In order to handle this SharePoint has defined its own function STSValidatorEnable with an extra parameter bSilent, so it can turn on validators without them firing.
They then found out that for some validators they always want them not to fire when STSValidatorEnable is called, even though the caller uses bSilent==false. So they introduced an attribute AlwaysEnableSilent which tells the validator never to fire when turned on using STSValidatorEnable, but only during postback.

'[Inspectable]' metadata tag

Anyone can explain briefly about the [Inspectable] metadata tag. I read and could not understand in live docs.
Please help me when we are going to use the [Inspectable] metadata tag?
Thanks,
ravi
The tag is used with properties to provide code hints for that property and to specify the possible list of values that property can take while using it in mxml. Unlike [Bindable] metadata, this tag doesn't have much effect on the working of the code (other than specifying a default value) - this is used mainly to give directions to Flex Builder regarding how to deal with a particular property.
[Inspectable] metadata tag
Defines an attribute exposed to component users in the attribute hints and Tag inspector of Flex Builder. Also limits allowable values of the property.
For example, the verticalScrollPolicy property of the mx.core.Container class has the following [Inspectable] tag with it.
[Inspectable(category="General", enumeration="off,on,auto", defaultValue="auto")]
public function get verticalScrollPolicy():String
{
return _verticalScrollPolicy;
}
This tells Flex Builder that this property should appear in the 'General' tab (it is 'Common' in my FB) of the Flex Builder's property inspector (open an mxml file, go to the Windows menu and select Flex Properties to open the property inspector - towards the upper side of inspector tab, near its title, you will find buttons to switch to standard view, category view, and alphabetical view). This property can take one of the three values off, on, auto and if none is specified it takes auto as its default value.
I've never used this tag and I believe you too won't be using it much unless you are writing a Flex API to be used by a bigger audience than your colleagues (or if you are a perfectionist).
This tag is useful for when you write your own custom components. While it does not interact with the actual code you write (unlike the [Bindable] tag, mentioned above), it does give the Flexbuilder environment a way of allowing the user to set properties of your component using the UI Designer.
Therefore, the tag is useful if you want to:
Write components that are to be used by other people (make only the publicly accessible properties Inspect'able)
You've written a custom component that is used multiple times in your UI (maybe an extended slider). You then write some Inspect'able getter/setter methods as the public API to your component, and then implement these getter/setter methods to do data validation and implement the internal logic of your component.
You can find more information and examples here. Some good info on writing custom components (using the code behind methodology, which I prefer) can be found here.
Note: When creating exposed properties using [Inspectable], they don't seem to show up in the Flexbuilder Flex-Properties panel (not in Standard view anyway, use Category view or Alphabetical view, instead)
Note: You can find an alternative method of adding public properties to your custom components using MXLM, like this.