How to create a dropzone in my div element? - dropzone.js
Notes : I tired all questions and answers related this topic.
I use form tag then work completely fine. See Code Here .
I want to "place" a drop zone in my div tag, but somehow it doesn't work. See the code here.
Snippet Example Below.
Dropzone.autoDiscover = false;
$("#mydropzone").dropzone({
//url: "/file/post",
addRemoveLinks: true,
maxFilesize: 0.5,
dictDefaultMessage: '<span class="text-center"><span class="font-lg visible-xs-block visible-sm-block visible-lg-block"><span class="font-lg"><i class="fa fa-caret-right text-danger"></i> Drop files <span class="font-xs">to upload</span></span><span>  <h4 class="display-inline"> (Or Click)</h4></span>',
dictResponseError: 'Error uploading file!'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/dropzone.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/dropzone.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/basic.css" rel="stylesheet"/>
<div class="clsbox-1" runat="server">
<div class="dropzone clsbox" id="mydropzone">
</div>
</div>
After a long research I have finally got the best solution.
HTML
<div class="clsbox-1" runat="server" >
div class="dropzone clsbox" id="mydropzone">
</div>
</div>
JavaScript
Dropzone.autoDiscover = false;
// Dropzone class:
var myDropzone = new Dropzone("div#mydropzone", { url: "/file/post"});
// If you use jQuery, you can use the jQuery plugin Dropzone ships with:
$("div#myDrop").dropzone({ url: "/file/post" });
JSFiddle Demo Here
Related
CKEDITOR: CKEDITOR.disableAutoInline = true not working
I have a div tag in my webpage <div id="editor1" name="editor1" contenteditable="true"> {!! $post->post !!} </div> When I click on the content of this div, a CKEditor Toolbar appears automatically. I tried to disable this Toolbar. I tried the following but could not be able to. Try 1 : <script> $(document).ready(function() { CKEDITOR.disableAutoInline = true; }); </script> Try 2: In the CKEditor config file config.disableAutoInline = true; What is my wrong? I am searching at Google, Stakeoverflow for several hours but not finding any solution. May I be helped by anybody? Note that: In the Page Header I added <link rel="stylesheet" href="http://localhost/ewt/resources\assets \ckeditor\plugins\codesnippet\lib\highlight\styles\magula.css"> and in the Footer I added <script src="http://localhost/ewt/resources/assets/ckeditor/ckeditor.js"> </script> <script src="http://localhost/ewt/resources/assets/ckeditor/adapters /jquery.js"></script> <script>hljs.initHighlightingOnLoad();</script>
I had the same problem, for me it started working when I set the disableAutoInline outside of document.ready: <script type="text/javascript"> CKEDITOR.disableAutoInline = true; $(document).ready(function () { ... } </script>
Eonasdan Bootstrap datetimepicker is not working
In my _Layout view I have this as scripts (also CSS have been added): <!-- jQuery --> <script src="/Content/themes/sb-admin-2/jquery/dist/jquery.min.js"></script> <!-- Bootstrap Core JavaScript --> <script src="/Content/themes/sb-admin-2/bootstrap/dist/js/bootstrap.min.js"></script> <!-- Morris Charts JavaScript --> <script src="/Content/themes/sb-admin-2/raphael/raphael-min.js"></script> <script src="/Content/themes/sb-admin-2/morrisjs/morris.min.js"></script> <script src="/Content/themes/sb-admin-2/js/morris-data.js"></script> <!-- Moment --> <script src="/Scripts/moment-with-locales.min.js"></script> <!-- DateTimePicker --> <script src="/Content/datetimepicker/bootstrap-datetimepicker.js"></script> <!-- Custom Theme JavaScript --> <script src="/Content/themes/sb-admin-2/js/sb-admin-2.js"></script> <script> $(document).ready(function () { debugger; $('.datetimepicker').datetimepicker({ sideBySide: true }); }); </script> And also, in my view where I want to show the datetimepicker I have this: <div class="row"> <div class="form-group col-md-6"> <label>Publish Date</label> <div class="input-group" id="datetimepicker"> #Html.TextBoxFor(x => x.PublishDate, new { #class = "form-control datetimepicker", placeholder = "Date", required = "required" }) <div class="input-group-addon"><i class="fa fa-calendar"> </i></div> </div> </div> </div> I tried many things to show the datetimepicker, have someone an idea of my problem? I don't have errors thrown in Console, I tried to debug but I didnt find nothing.
Your div has id="datetimepicker" but you are using selector for class ".datetimepicker". Try to change: $('.datetimepicker').datetimepicker({ sideBySide: true }); into $('#datetimepicker').datetimepicker({ sideBySide: true });
Ajax auto refresh - Not effecting scrolling
I am using ajax to auto refresh a div tag using this code in my index.php file: <script type="text/javascript"> $(document).ready(function() { $.ajaxSetup({ cache: false }); setInterval(function() { $('#messanges').load('messanges.php'); }, 1000); }); </script> <div id="messanges"></div> <textarea name="chat_input" id="chat_input"></textarea> In messanges.php I have a auto scroll down code. Cause I want it to start at the bottom when entering the chat. <head> <script> var chat_height = $('#chat').outerHeight(); $('#chat_box').scrollTop(chat_height); </script> </head> <div id="chat_box" style="height:700px; overflow:auto"> <div id="chat"> <div id="Name">Test user:</div> <div id="img"><img src="picture.png" /></img></div> <p class="triangle-isosceles left"> "Test" </p> </div> The code is now forcing the scroll to stay at the bottom because of the ajax auto refresh. How can I make it auto refresh, but if I want to scroll up it will not force me down when it refresh?
try some like this <head> <script> var chat_height = $('#chat').outerHeight(); if($('.doScroll').is(':checked')) { $('#chat_box').scrollTop(chat_height); } </script> </head> <input type="checkbox" class="doScroll" checked /> <div id="chat_box" style="height:700px; overflow:auto"> <div id="chat"> <div id="Name">Test user:</div> <div id="img"><img src="picture.png" /></img></div> <p class="triangle-isosceles left">"Test" </p> </div>
How to get the html of CKEditor
I am diving in the deep end of this magic world of HTML. I have the CKEditor woring and myFunction produces the alert. I need to get the HTML of the text in the editor. I got this from another post: CKEDITOR.instances.textarea.on( 'instanceReady', function( instanceReadyEventObj ) { var editorInstanceData = CKEDITOR.instances.textarea.getData(); alert( editorInstanceData ); }); I could not comment or reply to the post as I don't have enough points so I have to ask a duplicate. I have the alert working and pasted the code in myFunction but I get the error in the console Uncaught TypeError: Cannot call method 'on' of undefined. <!DOCTYPE html> <html> <head> <script> function myFunction() { var htmldata = CKEDITOR.instances.Editor.document.getBody().getHtml(); alert(htmldata); } </script> <title>A Simple Page with CKEditor</title> <!-- Make sure the path to CKEditor is correct. --> <script src="http://www.wilsea.com/ckeditor/ckeditor.js"></script> </head> <body> <form> <button onclick="myFunction()">Click me</button> <textarea id="editor1" name="editor1" rows="10" cols="80"> This is my textarea to be replaced with CKEditor..... </textarea> <script> // Replace the <textarea id="editor1"> with a CKEditor // instance, using default configuration. CKEDITOR.replace( 'editor1' ); </script> </form> </body> MrWarby <!DOCTYPE html> <html> <head> <script type="text/javaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="http://www.wilsea.com/ckeditor/ckeditor.js"></script> </head> <body> <textarea id="editor1" name="editor1" rows="10" cols="80"> This is my textarea to be replaced with CKEditor </textarea> <script> function myFunction() { alert('test'); CKEDITOR.instances.textarea.on( 'instanceReady', function( instanceReadyEventObj ) { var editorInstanceData = CKEDITOR.instances.textarea.getData(); alert( editorInstanceData ); }); } CKEDITOR.replace( 'editor1' ); </script> <p>Click the button to trigger a function.</p> <button onclick="myFunction()">Click me</button> <p id="demo"></p> </body> </html> I've tried moving into different place but I still get the same error. test page is at http://www.wilsea.com/ckeditor/testckeditor.html MrWarby.
Before your SCRIPT in HEAD add two more lines: <script type="text/javaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="/ckeditor/ckeditor.js"></script> But change path to CkEditor script.
two jqgrid no data loaded
When I duplicate a working grid with a different id, data are not loaded in both grid. Both grids are shown and they both query the same url. Json data is sent from php but data is not loaded into grid. If i comment any of the grids, the other one loads data properly. Any help greatly appreciated. I'm using jqgrid 4.4.1 Here is my code <div class="row-fluid"> <script type="text/javascript" language="javascript"> function LoadgridInput () { jQuery('#gridInput').jqGrid({ height:100, hoverrows:false, viewrecords:true, caption:" ",cellEdit: true,rowNum:10000, scroll:1, rowList:[30,100,500], datatype:"json", url:"grid.php?sec=Agility&fn=gcSandFInput_V1", cellurl:"grid.php?sec=Agility&fn=gcSandFInput_V1", editurl:"grid.php?sec=Agility&fn=gcSandFInput_V1", sortname:"default", autowidth:true, shrinkToFit:true, gridview:false, pager:"#gridInputPager", postData:{oper:"grid"}, jsonReader:{repeatitems:false,root: "rows",page: "page",total: "total",records: "records",repeatitems: true,cell: "cell",id: "id",userdata: "userdata"}, colModel:[ {name:" ",index:"nope",align:"left",search:true,editable:false,width:60},{name:"04-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"05-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"06-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"07-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"08-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"09-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"10-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"11-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"12-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"01-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"02-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"03-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"04-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"05-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"06-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"07-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"08-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"09-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"10-2013",index:"nope",align:"left",search:true,editable:false,width:60 }]}) jQuery('#gridInput').jqGrid('navGrid','#gridInputPager',{refresh:true,edit:false,add:false,del:false,search:true,view:false,"excel":true,"pdf":false,"csv":false,"columns":false},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"errorTextFormat":function(r){ return r.responseText;}},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"errorTextFormat":function(r){ return r.responseText;}},{"errorTextFormat":function(r){ return r.responseText;}}, {"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"closeAfterSearch":true,"multipleSearch":false},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150}); }; </script> <script type="text/javascript" language="javascript"> runOnLoad(LoadgridInput); </script> <div id="gridInputWrapper"> <table id="gridInput"></table> <div id="gridInputPager"></div> <div class="gridInputFooter"></div> </div> </div> <div class="row-fluid"> <script type="text/javascript" language="javascript"> function LoadgridList () { jQuery('#gridList').jqGrid({ height:100, hoverrows:false, viewrecords:true, caption:" ",cellEdit: true,rowNum:10000, scroll:1, rowList:[30,100,500], datatype:"json", url:"grid.php?sec=Agility&fn=gcSandFInput_V1", cellurl:"grid.php?sec=Agility&fn=gcSandFInput_V1", editurl:"grid.php?sec=Agility&fn=gcSandFInput_V1", sortname:"default", autowidth:true, shrinkToFit:true, gridview:false, pager:"#gridListPager", postData:{oper:"grid"}, jsonReader:{repeatitems:false,root: "rows",page: "page",total: "total",records: "records",repeatitems: true,cell: "cell",id: "id",userdata: "userdata"}, colModel:[ {name:" ",index:"nope",align:"left",search:true,editable:false,width:60},{name:"04-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"05-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"06-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"07-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"08-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"09-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"10-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"11-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"12-2012",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"01-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"02-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"03-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"04-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"05-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"06-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"07-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"08-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"09-2013",index:"nope",align:"left",search:true,editable:false,width:60 },{name:"10-2013",index:"nope",align:"left",search:true,editable:false,width:60 }]}) jQuery('#gridList').jqGrid('navGrid','#gridListPager',{refresh:true,edit:false,add:false,del:false,search:true,view:false,"excel":true,"pdf":false,"csv":false,"columns":false},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"errorTextFormat":function(r){ return r.responseText;}},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"errorTextFormat":function(r){ return r.responseText;}},{"errorTextFormat":function(r){ return r.responseText;}}, {"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"closeAfterSearch":true,"multipleSearch":false},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150}); }; </script> <script type="text/javascript" language="javascript">runOnLoad(LoadgridList);</script> <div id="gridListWrapper"> <table id="gridList"></table> <div id="gridListPager"></div> <div class="gridListFooter"></div> </div> </div>