Jquery itself is definitely great. However in some cases I just think those _onchange thing does not belong to View of MVC, it could be kind of necessary Control of MVC.
Besides, I prefer to write all relevant things in the same place like this: db.Field('foo', label='My label', requires=SOME_VALIDATOR(...), comment='if any', widget=lambda f,v:StringWidget.widget(f,v, _onchange='javascript:function(){...}()' ) Although you might argue that this is not MVC enough (well, in this maillist there was some discussion about when to use MVC and when not). If I do above in jquery way, do I have to separate some code into the views/myview.html? May I consider your answer "no major objection" as "yes, we will do it"? :-) On May29, 8:58pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > I have no major objction to changing the widget but it much easier to > handle this via jquery. > > Massimo > > On May 29, 7:54 am, Iceberg <iceb...@21cn.com> wrote: > > > Thanks for the reply. But title and label are different things. Title > > here refers to the pop-up yellow tooltip when your mouse hovers above > > the input area. Sometimes the app needs them both like this: > > <label>My label</label><input type='text' title='A longer > > description for this field'> > > > The proposal not only settles the need for _title, but also _onclick, > > _onchange, etc., if not _size. > > > On May29, 2:19am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > OK for subclassing object but there is already a way to change the > > > size > > > > <script> > > > $(document).ready(function(){$(#table_field).attr('size',80):}); > > > </script> > > > (I think this belongs to the view, not the widget, but if other people > > > agree with you....) > > > > and title > > > > db.table.field.label="My label" > > > > On May 28, 11:25 am, Iceberg <iceb...@21cn.com> wrote: > > > > > Hi Massimo, > > > > > Please consider to change sqlhtml.py 's StringWidget to: > > > > > class StringWidget(object): # I'll explain later > > > > @staticmethod > > > > def widget(field,value,**attributes): > > > > .... > > > > default_attributes=dict( > > > > _type='text', > > > > _id=id, > > > > _class=field.type, > > > > _name=field.name, > > > > value=str(value), > > > > requires=field.requires, > > > > ) > > > > default_attributes.update(attributes) > > > > return INPUT(**default_attributes) > > > > > This way, developers can customize the widget's _title or _size ... > > > > etc. much easily, like this: > > > > db.Field('addr','string',length=128, > > > > widget=lambda f,v: StringWidget.widget( > > > > f,v,_size=128,_title='Input your detail addr please')) > > > > > Without the suggested improvement, currently I have to subclass a new > > > > StringWidget to do that. > > > > > Another minor suggestion is to change StringWidget's base class to > > > > "object" (as I did in above example). This way the StringWidget will > > > > become a "new-style" python class. Then when people need to subclass > > > > it, they can use the python builtin super(...) function for more > > > > convenience. > > > > > These modifications are backward compatible. > > > > > Same suggestions apply to TextWidget, BooleanWidget, OptionsWidget, > > > > MultipleOptionsWidget, PasswordWidget, UploadWidget. > > > > > Please consider it. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---