I've fixed my problem using a simplier way :)
${h.textarea('db_content', style='visibility: hidden;')}
<script language="JavaScript" type="text/javascript">
var getdata =document.getElementById("db_content").value;
Instantiate("min","editor", getdata , "600px", "200px");
</script>
regards
P.
On Tue, Feb 17, 2009 at 4:43 PM, Tomasz Nazar <[email protected]>wrote:
> As far as I understand I have similar problem. Here's solution.
> (The topic it's not related to Pylons at all ;)
>
>
> Instead of direct output of i18n key's value:
> var x = '${_('my.key')}
>
> I do:
> * use Jquery to simplify (not required)
> * use mix of HTML/JS helpers
>
> A) Create html list of all keys accessed in the page:
> <pre id='translations' style='display: none'>
> <pre id='my.key'>${_('my.key')}</pre>
> <pre id='my.key2'>${_('my.key2')}</pre>
> .....
>
> B) Get all values into dict object
> <script>
> var translations = get_translations(); //code below
>
> C) access without \n\r problems
> var x = translations['my.key']
>
>
> var get_translations = function(){
> var dict = new Object();
> var jq_div = $('#translations > pre');
> for (var i=0; i<jq_div.length; i++){
> dict[jq_div[i].id] = jq_div[i].innerHTML;
> }
> return dict;
> }
> </script>
>
>
>
> On Wed, Feb 4, 2009 at 10:12 AM, przemek.ch <[email protected]> wrote:
> >
> > There's a nice wysiwyg/bbcode editor
> http://www.ecardmax.com/hoteditor/index.html.
> >
> > But I'm confused about one thing.
> >
> > The editor works like that:
> > <td>
> > <script>
> > var getdata ="[B]Test me[/B]";
> > Instantiate("min","editor", getdata , "600px", "200px");
> > </script>
> > </td>
> >
> > So the editor will be loaded and the content form getdata will be
> > added.
> >
> >
> > But there's one big problem wilt new line and return carriage
> > characters.
> >
> > Example:
> >
> > 1. Enter characters in new lines
> >
> > a
> > b
> > c
> >
> > 2. Save it into db as bbcode.
> > It will be saved as "a \n\r b \n\r c" - of course \n\r will not be
> > visible as string '\n\r'
> >
> > 3. Then I want to load that content to the editor from DB
> >
> > var getdata ="${h.content_form_db}";
> > Instantiate("min","editor", getdata , "600px", "200px");
> >
> >
> > And here's the problem, generated code looks like that:
> >
> > var getdata ="a
> > b
> > c";
> > Instantiate("min","editor", getdata , "600px", "200px");
> >
> > So it's not a valid js code and it will fail.
> >
> > Ok so I've done something like that:
> > Before i save bbcode content to db i replace \n to \\n and remove all
> > \r.
> > This works and now the generated code looks like that.
> >
> > var getdata ="a\nb\nc";
> > Instantiate("min","editor", getdata , "600px", "200px");
> >
> > But there's a new problem.
> > If a user will put into editor '\n' or '\r' string my replace method
> > will fail...
> >
> > Any suggestions?
> >
> > > >
> >
>
>
>
> --
> _i______'simplicity_is_the_key'__________tomasz_nazar
> _ii____'i_am_concern_oriented'________________JKM-UPR
> _iii__'patsystem.sf.net'___________________linux_user
> _'aspectized.com'___________________________prevayler
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---