How can I enable jquery validation on readonly fields?

Thank you for you suggestion Panoptik, adding readonly on focusin, and then removing it on focusout was the cleanest way, million thanks! I answer myself in case anyone has the same problem. Hope it helps. $(document).on(“focusin”, “#someid”, function() { $(this).prop(‘readonly’, true); }); $(document).on(“focusout”, “#someid”, function() { $(this).prop(‘readonly’, false); });

Why Tuple’s items are ReadOnly?

Tuples originated in functional programming. In (purely) functional programming, everything is immutable by design – a certain variable only has a single definition at all times, as in mathematics. The .NET designers wisely followed the same principle when integrating the functional style into C#/.NET, despite it ultimately being a primarily imperative (hybrid?) language. Note: Though … Read more

Java / Hibernate – Write operations are not allowed in read-only mode

That error message is typically seen when using the Spring OpenSessionInViewFilter and trying to do persistence operations outside of a Spring-managed transaction. The filter sets the session to FlushMode.NEVER/MANUAL (depending on the versions of Spring and Hibernate you’re using–they’re roughly equivalent). When the Spring transaction mechanism begins a transaction, it changes the flush mode to … Read more

How to make Entity Framework Data Context Readonly

In addition to connecting with a read-only user, there are a few other things you can do to your DbContext. public class MyReadOnlyContext : DbContext { // Use ReadOnlyConnectionString from App/Web.config public MyContext() : base(“Name=ReadOnlyConnectionString”) { } // Don’t expose Add(), Remove(), etc. public DbQuery<Customer> Customers { get { // Don’t track changes to query … Read more

How to get around lack of covariance with IReadOnlyDictionary?

You could write your own read-only wrapper for the dictionary, e.g.: public class ReadOnlyDictionaryWrapper<TKey, TValue, TReadOnlyValue> : IReadOnlyDictionary<TKey, TReadOnlyValue> where TValue : TReadOnlyValue { private IDictionary<TKey, TValue> _dictionary; public ReadOnlyDictionaryWrapper(IDictionary<TKey, TValue> dictionary) { if (dictionary == null) throw new ArgumentNullException(“dictionary”); _dictionary = dictionary; } public bool ContainsKey(TKey key) { return _dictionary.ContainsKey(key); } public IEnumerable<TKey> Keys … Read more

Immutable numpy array?

You can make a numpy array unwriteable: a = np.arange(10) a.flags.writeable = False a[0] = 1 # Gives: ValueError: assignment destination is read-only Also see the discussion in this thread: http://mail.scipy.org/pipermail/numpy-discussion/2008-December/039274.html and the documentation: http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flags.html