Twitter bootstrap 3.0 icon change on collapse

The collapse events are handled differently in Bootstrap 3. Now it would be something like: $(‘#collapseDiv’).on(‘shown.bs.collapse’, function () { $(“.glyphicon”).removeClass(“glyphicon-folder-close”).addClass(“glyphicon-folder-open”); }); $(‘#collapseDiv’).on(‘hidden.bs.collapse’, function () { $(“.glyphicon”).removeClass(“glyphicon-folder-open”).addClass(“glyphicon-folder-close”); }); Demo: http://www.bootply.com/73101

jQuery get text as number

Always use parseInt with a radix (base) as the second parameter, or you will get unexpected results: var number = parseInt($(this).find(‘.number’).text(), 10); A popular variation however is to use + as a unitary operator. This will always convert with base 10 and never throw an error, just return zero NaN which can be tested with … Read more

TinyMCE 4 – remove() or destroy()

I had the same problem. In v4 all suggestions above did not work for me, but this did: tinymce.remove(“div.editable”); … regenerated HTML dynamicaly … tinymce.init(…); I use inline editor: tinymce.init({ selector: “div.editable”, inline: true, plugins: [ “advlist autolink lists link image charmap print preview anchor”, “searchreplace visualblocks code fullscreen”, “insertdatetime media table contextmenu paste” ], … Read more

Unobtrusive Ajax stopped working after update jQuery to 1.9.0

Update: This issue has been fixed in the latest NuGet package. I’ve posted another answer to reflect this. https://stackoverflow.com/a/15539422/714309 In jquery.unobtrusive-ajax.js, find and replace these four lines: $(“a[data-ajax=true]”).live(“click”, function (evt) { $(document).on(“click”, “a[data-ajax=true]”, function (evt) { $(“form[data-ajax=true] input[type=image]”).live(“click”, function (evt) { $(document).on(“click”, “form[data-ajax=true] input[type=image]”, function (evt) { $(“form[data-ajax=true] :submit”).live(“click”, function (evt) { $(document).on(“click”, “form[data-ajax=true] :submit”, … Read more

Watching for DOM changes, the elegant way

Would this work? http://darcyclarke.me/development/detect-attribute-changes-with-jquery/ $.fn.watch = function(props, callback, timeout){ if(!timeout) timeout = 10; return this.each(function(){ var el = $(this), func = function(){ __check.call(this, el) }, data = { props: props.split(“,”), func: callback, vals: [] }; $.each(data.props, function(i) { data.vals[i] = el.css(data.props[i]); }); el.data(data); if (typeof (this.onpropertychange) == “object”){ el.bind(“propertychange”, callback); } else if ($.browser.mozilla){ el.bind(“DOMAttrModified”, … Read more

Does the order of elements in a jQuery-wrapped set always match the order in which the elements appear in the markup?

Just been looking at this myself. jQuery does return things in document order as per the following article: http://docs.jquery.com/Release:jQuery_1.3.2 So, if you select some ids as such: $(“#id1, #id2, #id3”) Then they will be returned in the order they appear in the DOM, not necessarily in the order they are given. Its certainly worth being … Read more