Angular and mixing jQuery UI – Why not?

Using JQuery like this means that you are not declaratively expressing what your app does in the HTML which is kind of the point of Angular. From the angular homepage: AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop. Your also going to run … Read more

jQueryUI tooltip Widget to show tooltip on Click

Using jqueryui: HTML: <div id=”tt” >Test</div> JS: $(‘#tt’).on({ “click”: function() { $(this).tooltip({ items: “#tt”, content: “Displaying on click”}); $(this).tooltip(“open”); }, “mouseout”: function() { $(this).tooltip(“disable”); } }); You can check it using http://jsfiddle.net/adamovic/A44EB/ Thanks Piradian for helping improve the code.

Adding jQueryui Buttons to dynamically added content

When you reload via ajax, call .button() (or whatever variant you’re using) in that context, like this: $.ajax({ //other options.. success: function(data) { //insert elements $(“.button”, data).button(); } }); This will run .button() on elements only in the response (not the others already in the page/DOM elsewhere) with class=”button”. You can’t really use .live() or … Read more

PreventDefault alternative for IE8

I use something like: (event.preventDefault) ? event.preventDefault() : event.returnValue = false; the event.returnValue property is the closest IE equivalent to preventDefault. Using return false; can sometimes also work, but it can lead to unexpected behavior sometimes when mixed with e.g. jQuery (jQuery also does stopPropagation…which is usually what you want, but…), so I prefer not … Read more

How to use jQuery UI with Angular 2

I managed to make it work by doing the following steps: npm uninstall jquery jquery-ui npm cache clean npm install jquery jquery-ui In angular-cli.json I added my jquery and jquery-ui paths in the scripts object. Here is what they look: “scripts”: [ “../node_modules/jquery/dist/jquery.min.js”, “../node_modules/jquery-ui/jquery-ui.js” ] After I completed these steps, it worked like a charm. … Read more

jQuery document ready function

All three of the following syntaxes are equivalent: $(document).ready(handler) $().ready(handler) (this is not recommended) $(handler) Aliasing the jQuery Namespace When using another JavaScript library, we may wish to call $.noConflict() to avoid namespace difficulties. When this function is called, the $ shortcut is no longer available, forcing us to write jQuery each time we would … Read more