How do I set an attr_accessor for a dynamic instance variable?

this answer doesn’t pollutes the class space, example.. if i do mine.my_number 4 then the other instances of Mine will not get the my_4 method.. this happens because we use the singleton class of the object instead of the class. class Mine def my_number num singleton_class.class_eval { attr_accessor “my_#{num}” } send(“my_#{num}=”, num) end end a … Read more

jQuery attr(‘onclick’)

Do it the jQuery way (and fix the errors): $(‘#stop’).click(function() { $(‘#next’).click(stopMoving); // ^– missing # }); // <– missing ); If the element already has a click handler attached via the onclick attribute, you have to remove it: $(‘#next’).attr(‘onclick’, ”); Update: As @Drackir pointed out, you might also have to call $(‘#next’).unbind(‘click’); in order … Read more

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

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/

How to get an enum which is created in attrs.xml in code

There does not seem to be an automated way to get a Java enum from an attribute enum – in Java you can get the numeric value you specified – the string is for use in XML files (as you show). You could do this in your view constructor: TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.IconView, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)