How can I get the content of CKEditor using JQuery?

use the CKEditor.editor.getData() call on the instance. That is to say: HTML <textarea id=”my-editor”> <input id=”send” type=”button” value=”Send”> JS for CKEditor 4.0.x $(‘#send’).click(function() { var value = CKEDITOR.instances[‘DOM-ID-HERE’].getData() // send your ajax request with value // profit! }); JS for CKEditor 3.6.x var editor = CKEDITOR.editor.replace(‘my-editor’); $(‘#send’).click(function() { var value = editor.getData(); // send your …

Read more

HTML5 with jQuery – e.offsetX is undefined in Firefox

Try using layerX and layerY for Firefox and offsetX for other browser. If event fired with jquery: xpos = e.offsetX === undefined ? e.originalEvent.layerX : e.offsetX; ypos = e.offsetY === undefined ? e.originalEvent.layerY : e.offsetY; If event fired with javascript: xpos = e.offsetX==undefined?e.layerX:e.offsetX; ypos = e.offsetY==undefined?e.layerY:e.offsetY;

Why is my JQuery selector returning a n.fn.init[0], and what is it?

Another approach(Inside of $function to asure that the each is executed on document ready): var ids = [1,2]; $(function(){ $(‘.checkbox-wrapper>input[type=”checkbox”]’).each(function(i,item){ if(ids.indexOf($(item).data(‘id’)) > -1){ $(item).prop(“checked”, “checked”); } }); }); Working fiddle: https://jsfiddle.net/robertrozas/w5uda72v/ What is the n.fn.init[0], and why it is returned? Why are my two seemingly identical JQuery functions returning different things? Answer: It seems that …

Read more

jquery doesn’t call success method on $.ajax for rails standard REST DELETE answer

I have run across this a few times and the answer is deceptively simple. You are using dataType : ‘json’ in your $.ajax call, so jQuery is expecting a JSON response. With head :ok Rails returns a response containing a single space (http://github.com/rails/rails/issues/1742), which is not accepted by jQuery as valid JSON. So if you …

Read more

How to add click event to a iframe with JQuery

There’s no ‘onclick’ event for an iframe, but you can try to catch the click event of the document in the iframe: document.getElementById(“iframe_id”).contentWindow.document.body.onclick = function() { alert(“iframe clicked”); } EDIT Though this doesn’t solve your cross site problem, FYI jQuery has been updated to play well with iFrames: $(‘#iframe_id’).on(‘click’, function(event) { }); Update 1/2015 The …

Read more

The specified value does not conform to the required format yyyy-MM-dd

The specifications for the HTML5 date picker state that the date must be in the format yyyy-MM-dd (ISO format). This means that you DisplayFormatAttribute must be [DisplayFormat(DataFormatString = “{0:yyyy-MM-dd}”, ApplyFormatInEditMode = true)] public string MyDate { get; set; } Alternatively you can manually add the format using @Html.TextBoxFor(m => m.MyDate, “{0:yyyy-MM-dd}”, new { @type = …

Read more

jQuery Passing $(this) to a Function

you can check this link. http://jsfiddle.net/zEXrq/38/ $(“#f”).click(function() { myFunc($(this)); }) function myFunc(thisObj) { thisObj.parent().parent().children().each(function() { alert(“childs”) }); } <div id=”wordlist”> <div id=”a”></div> <div id=”b”> <div id=”e”></div> <div id=”f”>child</div> </div> </div> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>