Store JSON object in data attribute in HTML jQuery

Actually, your last example: <div data-foobar=”{“foo”:”bar”}”></div> seems to be working well (see http://jsfiddle.net/GlauberRocha/Q6kKU/). The nice thing is that the string in the data- attribute is automatically converted to a JavaScript object. I don’t see any drawback in this approach, on the contrary! One attribute is sufficient to store a whole set of data, ready to … Read more

jquery save json data object in cookie

You can serialize the data as JSON, like this: $.cookie(“basket-data”, JSON.stringify($(“#ArticlesHolder”).data())); Then to get it from the cookie: $(“#ArticlesHolder”).data(JSON.parse($.cookie(“basket-data”))); This relies on JSON.stringify() and JSON.parse() to serialize/deserialize your data object, for older browsers (IE<8) include json2.js to get the JSON functionality. This example uses the jQuery cookie plugin

jQuery easing functions without using a plugin

Provided that you follow the BSD licensing provisions, you can cherry-pick the easing functions that you want directly from the jQuery UI source code. Note that some of these functions depend on other functions within the list. To view and compare these easing functions in action, see: http://api.jqueryui.com/easings/ /* * jQuery Easing v1.3 – http://gsgd.co.uk/sandbox/jquery/easing/ … Read more

from jquery $.ajax to angular $http

The AngularJS way of calling $http would look like: $http({ url: “http://example.appspot.com/rest/app”, method: “POST”, data: {“foo”:”bar”} }).then(function successCallback(response) { // this callback will be called asynchronously // when the response is available $scope.data = response.data; }, function errorCallback(response) { // called asynchronously if an error occurs // or server returns response with an error status. … Read more

Select2 doesn’t work when embedded in a bootstrap modal

Ok, I’ve got it to work. change <div id=”myModal” class=”modal hide fade” tabindex=”-1″ role=”dialog” aria-labelledby=”myModalLabel” aria-hidden=”true”> <div class=”modal-header”> <button type=”button” class=”close” data-dismiss=”modal” aria-hidden=”true”>×</button> <h3 id=”myModalLabel”>Panel</h3> </div> <div class=”modal-body” style=”max-height: 800px”> to <div id=”myModal” class=”modal hide fade” role=”dialog” aria-labelledby=”myModalLabel” aria-hidden=”true”> <div class=”modal-header”> <button type=”button” class=”close” data-dismiss=”modal” aria-hidden=”true”>×</button> <h3 id=”myModalLabel”>Panel</h3> </div> <div class=”modal-body” style=”max-height: 800px”> (remove tabindex=”-1″ … Read more