2015年6月27日 星期六

jQuery get url parameters

$.urlParam = function(name){
    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results==null){
       return null;
    }
    else{
       return results[1] || 0;
    }
}
 
console.log($.urlParam('param1'));




References :
Get URL parameters using jQuery

2015年6月19日 星期五

Flask WTForms example

References :
Reusing Flask-WTF forms. » BTHLabs
The Flask Mega-Tutorial, Part III: Web Forms - miguelgrinberg.com

WTForms dynamic set default SelectField value

myform = TestForm()
myform.select.default = 2
myform.process() // <-- :="" br="" missed="" this="" you="">
myform.title.data = 'xxxx'
....




References :
Change default value of a SelectField after form creation · Issue #106 · wtforms/wtforms

WTForms print validate error

print form.errors

WTForms Dynamic Select Field 'Not a Valid Choice' error

area = SelectField(coerce=int)




References :
python - Not a Valid Choice for Dynamic Select Field WTFORMS - Stack Overflow

WTForms get label text

{{ form.my_field.label.text }}




References :
accessing label property without html generation.. - Google Groups