Unable to set data attribute using jQuery Data() API

It is mentioned in the .data() documentation The data- attributes are pulled in the first time the data property is accessed and then are no longer accessed or mutated (all data values are then stored internally in jQuery) This was also covered on Why don’t changes to jQuery $.fn.data() update the corresponding html 5 data-* … Read more

NUnit Test Run Order

I just want to point out that while most of the responders assumed these were unit tests, the question did not specify that they were. nUnit is a great tool that can be used for a variety of testing situations. I can see appropriate reasons for wanting to control test order. In those situations I … Read more

Custom Compiler Warnings

This is worth a try. You can’t extend Obsolete, because it’s final, but maybe you can create your own attribute, and mark that class as obsolete like this: [Obsolete(“Should be refactored”)] public class MustRefactor: System.Attribute{} Then when you mark your methods with the “MustRefactor” attribute, the compile warnings will show. It generates a compile time … Read more

XML Serialization – Disable rendering root element of array

To disable rendering of root element of collection, you must replace the attribute [XmlArrayItem] with [XmlElement] in your code. For removing the xsi and xsd namespaces, create an XmlSerializerNamespaces instance with an empty namespace and pass it when you need to serialize your object. Take a look on this example: [XmlRoot(“SHOPITEM”)] public class ShopItem { … Read more

Set attributes from dictionary in python

Sure, something like this: class Employee(object): def __init__(self, initial_data): for key in initial_data: setattr(self, key, initial_data[key]) Update As Brent Nash suggests, you can make this more flexible by allowing keyword arguments as well: class Employee(object): def __init__(self, *initial_data, **kwargs): for dictionary in initial_data: for key in dictionary: setattr(self, key, dictionary[key]) for key in kwargs: setattr(self, … Read more

Test if a class has an attribute?

check that Attribute.GetCustomAttribute(typeof(ScheduleController), typeof(SubControllerActionToViewDataAttribute)) isn’t null (Assert.IsNotNull or similar) (the reason I use this rather than IsDefined is that most times I want to validate some properties of the attribute too….)

javascript remove “disabled” attribute from html input

Set the element’s disabled property to false: document.getElementById(‘my-input-id’).disabled = false; If you’re using jQuery, the equivalent would be: $(‘#my-input-id’).prop(‘disabled’, false); For several input fields, you may access them by class instead: var inputs = document.getElementsByClassName(‘my-input-class’); for(var i = 0; i < inputs.length; i++) { inputs[i].disabled = false; } Where document could be replaced with a … Read more

Get all attributes of an element using jQuery

The attributes property contains them all: $(this).each(function() { $.each(this.attributes, function() { // this.attributes is not a plain object, but an array // of attribute nodes, which contain both the name and value if(this.specified) { console.log(this.name, this.value); } }); }); What you can also do is extending .attr so that you can call it like .attr() … Read more

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