Hi all,

I have a textfield which I am rendering as a TinyMCE widget. So the
value entered in this text field is passed in html format to the
server. I want to trim leading and trailing whitespaces from the
value. Since the value sent back is always in following format:
<p> some value </p>, even though I use strip/rstrip/lstrip functions,
they are of no use.
I am currently trying to modify render(self, name, value, attrs=None):
function in tinymce/widgets.py as there the function call is directed.
Something like this:

    def render(self, name, value, attrs=None):
        if value is None: value = ''
        value = smart_unicode(value)
        value = value.strip()
        final_attrs = self.build_attrs(attrs)
        final_attrs['name'] = name
        assert 'id' in final_attrs, "TinyMCE widget attributes must
contain 'id'"

        mce_config = mygo.tinymce.settings.DEFAULT_CONFIG.copy()
        mce_config.update(get_language_config(self.content_language))
        if mygo.tinymce.settings.USE_FILEBROWSER:
            mce_config['file_browser_callback'] = "djangoFileBrowser"
        mce_config.update(self.mce_attrs)
        mce_config['mode'] = 'exact'
        mce_config['elements'] = final_attrs['id']
        mce_config['strict_loading_mode'] = 1
        mce_json = simplejson.dumps(mce_config)


        html = [u'<textarea%s>%s</textarea>' % (flatatt(final_attrs),
escape(value))]
        if mygo.tinymce.settings.USE_COMPRESSOR:
            compressor_config = {
                'plugins': mce_config.get('plugins', ''),
                'themes': mce_config.get('theme', 'advanced'),
                'languages': mce_config.get('language', ''),
                'diskcache': True,
                'debug': False,
            }
            compressor_json = simplejson.dumps(compressor_config)
            html.append(u'<script type="text/
javascript">tinyMCE_GZ.init(%s)</script>' % compressor_json)
        html.append(u'<script type="text/javascript">tinyMCE.init(%s)</
script>' % mce_json)

        return mark_safe(u'\n'.join(html))


But somehow it is not getting reflected. When I replaced value with
some hard string like 'Sonal' and use .strip(), then it works, so I
guessing the type of value variable here. Did anybody have this
problem??

Joost, Can you please tell me what I am doing wrong here?

Thanks in advance,

Sincerely,
Sonal.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to