Hide/Show nicEdit using buttons -
i have following nicedit:
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"> <script type="text/javascript" src="../nicedit.js"></script> <script type="text/javascript"> bklib.ondomloaded(function() { niceditors.alltextareas() }); </script> <h4 style="text-align:center;">generate job overview</h4> <p> within overview, please make note of necessary information, conditions, expectations , etc better assist freelancer review. </p> <textarea id="createjob" name="area3" class="col-xs-8 col-sm-8 col-md-8 col-lg-8" style="width: 100%; height: 50%;"> html <b>content</b> <i>default</i> in textarea </textarea> <button type="submit" class="btn btn-primary" onclick="edittexteditor()" style="background-color:#006dcc;">edit</button> <button type="submit" class="btn btn-primary" onclick="submittexteditor()" style="background-color:#006dcc;">submit</button> </div>
installed using: http://nicedit.com/
i trying use function so:
function submittexteditor() { document.getelementbyid(".nicedit-panelcontain").style.color = "red"; $(".nicedit-panelcontain").css("display", "none"); } function edittexteditor() { document.getelementbyid(".nicedit-panelcontain").style.color = "red"; $(".nicedit-panelcontain").css("display", "block"); }
to attempt not hide panel editing make text readonly. not sure how go this. functions above tried using id of textarea "createjob" no luck. suggestions?
i tried referencing how set nicedit uneditable didn't work examples either
i show you, how did it.
if edit text, use dblclick can use other action. objid special attribut set, can use div id or name.
my niceditconfig.
niceditconfig: { onclose: function(content, id, instance){ $('div.nicedit-pane').hide(); instance.ne.removeinstance(id); instance.ne.removepanel(); $('#'+id).html($('#'+id).data('oldcontent')); $(id).attr('contenteditable','false'); var container = 'wiki_content_edit-'+$('input#contentid').val(); $('#'+container).hide(); $('#wiki_content_viewbox').show().click(); }, onsave : function(content, id, instance) { $('div.nicedit-pane').hide(); wiki_save_content(content); var container = 'wiki_content_edit-'+$('input#contentid').val(); $('#'+container).hide(); $('#wiki_content_viewbox').show().click(); instance.ne.removeinstance(id); instance.ne.removepanel(); $(id).attr('contenteditable','false'); }, iconspath : '/img/niceditoricons.gif', buttonlist : ['close','save','fontformat','bold','italic','underline','ol','ul','link','unlink','image','fileupload','indent','outdent','xhtml','code'] }, $(document).on('dblclick','#wiki_content_view',function(){ mywiki.editcontent('wiki_content_edit_body',$(this).attr('objid')); });
the editcontent function. use different div's viewing , editing.
editcontent: function(elm,objid) { var oc = $('#'+elm).html(); var container = 'wiki_content_edit-'+objid; $('#'+elm).data('oldcontent',oc); // backup old content $('#'+elm).attr('contenteditable','true'); // make div editable $('div[id^=check]').buttonset(); $('#wiki_content_viewbox').hide(); $('#'+container).show(); createuploader('file-uploader'); var wikiniceditor = new niceditor(mywiki.niceditconfig); wikiniceditor.panelinstance(elm); $('#'+elm).focus(); var sticky_panelcontain_offset_top = $('div.nicedit-panelcontain').offset().top; var sticky_panelcontainer = function(){ var scroll_top = $(window).scrolltop(); if (scroll_top > sticky_panelcontain_offset_top) { $('div.nicedit-panelcontain').css({ 'position': 'fixed', 'top':0, 'left':0 }); } else { $('div.nicedit-panelcontain').css({ 'position': 'relative' }); } }; sticky_panelcontainer(); $(window).scroll(function() { sticky_panelcontainer(); }); },
i use sticky_panelcontainer have nicedit panel @ top of page if have long text , must scroll.
and here save , close functions. use nicedit buttons , function calls.
saveeditcontent: function(elm) { $('#'+elm).focus(); var wikiniceditor = niceditors.findniceditor(elm); var inst = wikiniceditor.instancebyid(elm); var bsave = inst.ne.nicpanel.findbutton('save'); bsave.mouseclick(); }, closeeditcontent: function(elm) { $('#'+elm).focus(); var wikiniceditor = niceditors.findniceditor(elm); var inst = wikiniceditor.instancebyid(elm); var bclose = inst.ne.nicpanel.findbutton('close'); bclose.mouseclick(); $(window).off('scroll'); },
i hope bring on right way.
Comments
Post a Comment