Categories | Question details Back To List | ||||||||||||||
I want to replace the \n by in the textarea because the function javascript replace() doesn't work. Exemple: ... I want to replace the \n by <br> in the textarea because the function javascript replace() doesn't work. Exemple: scheduler.templates.event_text=function(start,end,event) { return "Text:<b> "+event.text+"</b><br> "+event.details.replace(/\n/g,"<br>"); } Answer posted by Alex (support) on Nov 27, 2009 07:25 locally this approach works. It adds the formatted value of details property to the events text. But event_text template isn't applied to text in lightbox. Answer posted by abdel on Nov 27, 2009 08:16 it works but when i want to create a new event the view not appear perfectly. You have an another way in PHP for example. Sorry for my english. Answer posted by Alex (support) on Nov 30, 2009 01:00 is the problem still actual ? Please provide more details about it. Answer posted by abdel on Nov 30, 2009 01:43 The function replace() works but in my unit view when i want to create a new event, my select is not generate automatically. In the file attachement, the screenshots unit_whithout_function shows that the select "Assigné à " is selected according to the selected section and the bloc of event is displayed. In the other screenshots the display is different when i use the function replace(). Sorry for my english, i use google translate :-) Attachments (2)
Answer posted by Alex (support) on Nov 30, 2009 04:02 The issue isn't clear enough. Could you please provide more details. The working sample (without server side scripts) is preferable. Answer posted by Abdel on Nov 30, 2009 04:28 It is possible to use the function str_replace() in events.php for replace the " \n " by " <br>" ? Answer posted by Alex (support) on Nov 30, 2009 06:45 You can try to use beforeRender event of the connector: function custom_format($event){ $details = $event->get_value("details"); /*your code here*/ $event ->set_value(...); }$tree->event->attach("beforeRender",custom_format); Answer posted by abdel on Dec 01, 2009 01:21 Thank you, it works but in the textarea of lightbox html tags <br> appears. I'm use this function but i doesn't works. scheduler.form_blocks.textarea.get_value=function(node,value,ev){ return node.firstChild.value.replace(/<br>/, '<p>'); } Answer posted by abdel on Dec 01, 2009 01:21 scheduler.form_blocks.textarea.get_value=function(node,value,ev){ return node.firstChild.value.replace(/<br>/, '\n'); } Sorry Answer posted by Alex (support) on Dec 01, 2009 03:19 Probably you should redefine the set_value method. Answer posted on Dec 04, 2009 03:58 In events.php i have this : function custom_format($event){ $details = $event->get_value("details"); $event ->set_value("details",str_replace("\n","<br>",$details)); } $scheduler = new schedulerConnector($res); $scheduler->enable_log("log.txt",true); $scheduler->event->attach("beforeRender",custom_format); $scheduler->render_sql("select * from events","event_id","start_date,end_date,event_name,details,section_id,type_id"); But in my textarea, the tags <br> display. Answer posted by Alex (support) on Dec 04, 2009 05:18 Method $event ->set_value("details",str_replace("\n","<br>",$details)); replaces \n with <br> tags - that is why <br> are displayed. The details can be also formatted on client: scheduler.form_blocks.textarea.set_value=function(node,value,ev){ |