Use declare styleable to set custom component input type

Lets say you have a custom view named InputView, which is not a TextView (lets say its a RelativeLayout). In your attrs.xml: <declare-styleable name=”InputView”> <!– any custom attributes –> <attr name=”title” format=”string” /> <!– standart attributes, note android: prefix and no format attribute –> <attr name=”android:imeOptions”/> <attr name=”android:inputType”/> </declare-styleable> In an xml layout where you …

Read more

Conditionally make input field readonly in Angular 2 or 4: Advice + Best/which way to do it

You need to use the following (Angular 4): <input [readonly]=”isReadOnly”> If you use att.readonly then the input will always be read-only because the readonly attribute will be present even if its value is false. By using [readonly] Angular will only place the attribute if isReadOnly is true. In HTML, the following is sufficient to cause …

Read more

How do I add selectableItemBackground to an ImageButton programmatically?

Here is an example using answer here: How to get the attr reference in code? // Create an array of the attributes we want to resolve // using values from a theme // android.R.attr.selectableItemBackground requires API LEVEL 11 int[] attrs = new int[] { android.R.attr.selectableItemBackground /* index 0 */}; // Obtain the styled attributes. ‘themedContext’ …

Read more

jQuery .attr(“disabled”, “disabled”) not working in Chrome

If you are using jQuery < 1.6 do this: jQuery(“input[type=”text”]”).attr(“disabled”, ‘disabled’); If you are using jQuery 1.6+: jQuery(“input[type=”text”]”).prop(“disabled”, true); See this question: .prop() vs .attr() for references why. Or you can try this: $(‘input:text’).attr(“disabled”, ‘disabled’); see here for info on :text

jquery: get value of custom attribute

You need some form of iteration here, as val (except when called with a function) only works on the first element: $(“input[placeholder]”).val($(“input[placeholder]”).attr(“placeholder”)); should be: $(“input[placeholder]”).each( function () { $(this).val( $(this).attr(“placeholder”) ); }); or $(“input[placeholder]”).val(function() { return $(this).attr(“placeholder”); });

Setting new value for an attribute using jQuery

Works fine for me See example here. http://jsfiddle.net/blowsie/c6VAy/ Make sure your jquery is inside $(document).ready function or similar. Also you can improve your code by using jquery data $(‘#amount’).data(‘min’,’1000′); <div id=”amount” data-min=””></div> Update, A working example of your full code (pretty much) here. http://jsfiddle.net/blowsie/c6VAy/3/

jQuery find elements with value = x

If the value is hardcoded in the source of the page using the value attribute then you can $(‘#attached_docs :input[value=”123″]’).remove(); or $(‘#attached_docs :input’).filter(function(){return this.value==’123′}).remove(); demo http://jsfiddle.net/gaby/RcwXh/2/