How to programmatically select selectables with jQuery UI?

Here is a variation of Alex R’s code working with multiple elements http://jsfiddle.net/XYJEN/1/ function SelectSelectableElements (selectableContainer, elementsToSelect) { // add unselecting class to all elements in the styleboard canvas except the ones to select $(“.ui-selected”, selectableContainer).not(elementsToSelect).removeClass(“ui-selected”).addClass(“ui-unselecting”); // add ui-selecting class to the elements to select $(elementsToSelect).not(“.ui-selected”).addClass(“ui-selecting”); // trigger the mouse stop event (this will select … Read more

jQuery remove tag from HTML String without RegEx

You can wrap your string in a jQuery object and do some sort of a manipulation like this: var removeElements = function(text, selector) { var wrapped = $(“<div>” + text + “</div>”); wrapped.find(selector).remove(); return wrapped.html(); } USAGE var removedSpanString = removeElements(“<span>Some Text</span> Some other Text”, “span”); The beauty of this approach is that you can … Read more

jqGrid with automatic height; but has a max height & scrollbars

I would recommend you to set “max-height” property on the bdiv of jqGrid and use height:’100%’ or height:’auto’: $(“#list”).parents(‘div.ui-jqgrid-bdiv’).css(“max-height”,”300px”); The “max-height” property will be not used by IE6, but more recent web browsers will use it. UPDATED: Free jqGrid introduce in version 4.10.0 new property: maxHeight which do exactly the same as above. Thus one … Read more

jQuery .slideRight effect

If you’re willing to include the jQuery UI library, in addition to jQuery itself, then you can simply use hide(), with additional arguments, as follows: $(document).ready( function(){ $(‘#slider’).click( function(){ $(this).hide(‘slide’,{direction:’right’},1000); }); }); JS Fiddle demo. Without using jQuery UI, you could achieve your aim just using animate(): $(document).ready( function(){ $(‘#slider’).click( function(){ $(this) .animate( { ‘margin-left’:’1000px’ … Read more

JavaScript – Escape double quotes

It should be: var str=”[{“Company”: “XYZ”,”Description”: “\\”TEST\\””}]”; First, I changed the outer quotes to single quotes, so they won’t conflict with the inner quotes. Then I put backslash before the innermost quotes around TEST, to escape them. And I escaped the backslash so that it will be treated literally. You can get the same result … Read more

JQuery Datepicker – no default date

I got round the problem using a hidden altField: <div id=”DatePicker”></div> <input type=”hidden” value=”” name=”Date” id=”Date” /> and the following script: <script> $(function () { $(‘#DatePicker’).datepicker({ altField: ‘#Date’, // ID of the hidden field altFormat: ‘dd/mm/yy’ }); // Remove the style for the default selected day (today) $(‘.ui-datepicker-current-day’).removeClass(‘ui-datepicker-current-day’); // Reset the current selected day $(‘#Date’).val(”); … Read more

Jquery to open Bootstrap v3 modal of remote url

So basically, in jquery what we can do is to load href attribute using the load function. This way we can use the url in <a> tag and load that in modal-body. <a href=”https://stackoverflow.com/site/login” class=”ls-modal”>Login</a> //JS script $(‘.ls-modal’).on(‘click’, function(e){ e.preventDefault(); $(‘#myModal’).modal(‘show’).find(‘.modal-body’).load($(this).attr(‘href’)); });

HTTPS and external (CDN) hosted files?

Assuming the CDN provider has an https version, you can use protocol-relative URLs. For example, instead of: http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js …you can use: //ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js The browser will use the page’s protocol to try to obtain the file. On non-secure pages, http. On secure pages, https. Google also makes YUI Loader available through its CDN. So for YUI … Read more