close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Passing data to HTML Editor inserted in bootstrap modal

Thread began 2/14/2017 12:23 pm by danielsebas | Last modified 2/15/2017 2:15 pm by Ray Borduin | 480 views | 5 replies |

danielsebas

Passing data to HTML Editor inserted in bootstrap modal

Hi, I am trying to pass data to a html editor inserted in a bootstrap 3 modal for an update form, all the values are passed like this to the modal:

<a data-toggle="modal" data-id="<?php echo($fotos->getColumnVal("floresID")); ?>" data-nombre="<?php echo($fotos->getColumnVal("fotosNOM")); ?>" data-posicion="<?php echo($fotos->getColumnVal("fotosORD")); ?>" data-descripcion="<?php echo($fotos->getColumnVal("fotosDES")); ?>" class="open-egresoInventario" href="#egresoInventario"><img src="../media/icons/edit_1.png" alt=""/></a>



This is the script to put the code in the modal:

<script>
$(document).on("click", ".open-egresoInventario", function () {
var prodID = $(this).data('id');
$(".modal-body #prodID").val( prodID );
var nombre = $(this).data('nombre');
$(".modal-body #nombre").val( nombre );
var posicion = $(this).data('posicion');
$(".modal-body #posicion").val( posicion );
});
</script>



And the modal goes like this:

<!-- Begin Modal -->
<div id="egresoInventario" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-lg" role="document">
<!-- Modal content-->
<form enctype="multipart/form-data" class="Cool_Default" id="Egreso_inventario" name="Egreso_inventario" method="post" action="<?php echo (htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)); ?>">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<input id="nombre" name="nombre" type="text" value="" class="formTextfield_Large" style="margin-bottom: 10px" title="Campo obligatorio" placeholder="Nombre de producto" required="true">
<input id="posicion" name="posicion" type="text" value="" class="formTextfield_Large" style="margin-bottom: 10px" title="Campo obligatorio" placeholder="PosiciĆ³n" required="true">
<input type="hidden" name="egresoprodID" id="prodID" value=""/>
<input type="hidden" name="egresoEST" id="egresoEst" value="2"/>
<?php
// The initial value to be displayed in the editor.
$CKEditor_initialValue = "";
$CKEditor = new CKEditor();
$CKEditor->basePath = "../webassist/ckeditor/";
$CKEditor_config = array();
$CKEditor_config["wa_preset_name"] = "Dewalt";
$CKEditor_config["wa_preset_file"] = "Dewalt.xml";
$CKEditor_config["width"] = "100%";
$CKEditor_config["height"] = "200px";
$CKEditor_config["docType"] = "<" ."!" ."DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
$CKEditor_config["contentsLanguage"] = "es";
$CKEditor_config["dialog_startupFocusTab"] = false;
$CKEditor_config["fullPage"] = true;
$CKEditor_config["tabSpaces"] = 4;
$CKEditor_config["toolbar"] = array(
array( 'Bold','Italic','-','NumberedList','BulletedList'),
array( 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
array( 'Format'),
array( 'BidiLtr','BidiRtl'),
array( 'Table','HorizontalRule','Smiley','SpecialChar'),
array( 'Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker','Scayt'),
array( 'Link','Unlink'),
array( 'Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'));
$CKEditor_config["contentsLangDirection"] = "ltr";
$CKEditor_config["entities"] = false;
$CKEditor_config["pasteFromWordRemoveFontStyles"] = false;
$CKEditor_config["pasteFromWordRemoveStyles"] = false;
$CKEditor->editor("descripcion", $CKEditor_initialValue, $CKEditor_config);
?>

</div>
<div class="modal-footer">
<input class="formButton" name="Egreso_submit" type="submit" id="Egreso_submit" value="Registrar Egreso">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
</div>
</form>
</div>
</div>
<!-- End Modal -->



I can pass all the info to the fields in the modal but I cannot pass it to the HTML Editor. Any clues on how to do that? the info I want to pass to the HTML Editor is from data-descripcion

Sign in to reply to this post

Ray BorduinWebAssist

You can use the ckeditor method setData like:

CKEDITOR.instances["descripcion"].setData($(this).data('descripcion'));
Sign in to reply to this post

danielsebas

Thank you Ray, I don't know were to put that line of code

Sign in to reply to this post

Ray BorduinWebAssist

I'm guessing you need something like:

<script>
$(document).on("click", ".open-egresoInventario", function () {
var prodID = $(this).data('id');
$(".modal-body #prodID").val( prodID );
var nombre = $(this).data('nombre');
$(".modal-body #nombre").val( nombre );
var posicion = $(this).data('posicion');
$(".modal-body #posicion").val( posicion );

var descripcion= $(this).data('descripcion');
CKEDITOR.instances["descripcion"].setData(descripcion);
});
</script>
Sign in to reply to this post

danielsebas

Thank you Ray, it worked perfectly! Is there any ajax option for the update behavior within WA MYSQLi extension?

Sign in to reply to this post

Ray BorduinWebAssist

Sure. You could apply the server behaviors to a blank page and then post to them from AJAX. Anything can work in an AJAX environment it is a matter of how you apply it and access it, not the code itself.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...