Blog Archives

Before save Image preview on upload and Remove Image/ Remove Image after save

Note: f -> form-for object/ FormBuilder Object, incase if you wants to use image preview for fields_for then pass fields_for object to image_preview helper method In html.erb file <%= image_preview(f) %> In helper file def image_preview(f) url, style = f.object.image.present?

Tagged with: , , ,
Posted in html.erb, JQuery, Ruby Little Codes

Bootstrap DatePicker events

Altoough JQuery UI provides datepicker. But I noticed that there are difference in working and methods of JQuery UI and bootstrap-datepicker. So first check in your application.js file. If the line below is written there then its bootstrap-datepicker and you

Tagged with: , , ,
Posted in JQuery

Select De-Select multiple check boxes

It Compare Length of all check-boxes with checked check-boxes if length of checked is less than all check-boxes then select all else unselect all. $(“#select-deselect-all”).click(function(){ var value; if ($(“.published:checked”).length < $(".published").length){ value = true }else if($(".published:checked").length == $(".published").length){ value =

Tagged with: ,
Posted in Html, JQuery

Change locale using Jquery / Change params value using jquery

$(function(){ $(“#page_locale”).change(function(){ var pre_locale = location.href.match(/locale=([a-z]{2})/)[1]; window.location = location.href.replace(‘locale=’+pre_locale,’locale=’+ this.value); }); }); This is core code var pre_locale = location.href.match(/locale=([a-z]{2})/)[1]; window.location = location.href.replace(‘locale=’+pre_locale,’locale=’+ this.value);

Tagged with: , , ,
Posted in JQuery

JQuery element’s Children

To get each level children even at lower level use .find() To get first level children excluding text nodes use .children() To get first level children including text nodes use .contents() .find(selector) Returns children, grand-children, grand-grand-children etc.  It return all

Tagged with: , , ,
Posted in JQuery

Jquery Checkbox check/ticked/clicked on click on some event triger in Ruby On Rails Enviornment

In Ruby on Rails Enviornment Checkbox/checkboxes was not clicking on some event trigger 🙂 At last I found the way to do: Infact in rails when you creat a checkbox it will creat a span as its parrent element when

Posted in Client Side Technologies, JQuery, Ruby Little Codes

Bind an element which is not available on page load using jQuery

$(“a.offsite”).live(“click”, function(){ alert(“Goodbye!”); }); // jQuery 1.3+ $(document).delegate(“a.offsite”, “click”, function(){ alert(“Goodbye!”); }); // jQuery 1.4.3+ $(document).on(“click”, “a.offsite”, function(){ alert(“Goodbye!”); }); // jQuery 1.7+ For more Details: http://api.jquery.com/live/ http://api.jquery.com/delegate/

Tagged with: , ,
Posted in Client Side Technologies, JQuery

Ajax callbacks oncomplete, error, success For rails

ajax:beforeSend – fired before the send occurs ajax:success – fired after the send occurs, contains the response ajax:complete – fired after the success event ajax:error – fired when errors are present $(document).ready( function(){ $(“a#ajax_trigger”).bind(“ajax:success”, function(evt, data, status, xhr){ //this assumes

Posted in JQuery, Ruby on Rails

create, read, delete cookies JavaScript/jquery

function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = “; expires=”+date.toGMTString(); } else var expires = “”; document.cookie = name+”=”+value+expires+”; path=/”; } function readCookie(name) { var nameEQ = name + “=”; var ca =

Posted in Client Side Technologies, JQuery

NoMethodError – undefined method `render_to_string’ for #<#:0x007f95255e3c08>:

Question#1  Do I need to include anything special in order to call render_to_string from the view? When I try to do something like this in my rhtml template: <%= render_to_string(:partial => “user_description”) %> I get the error: undefined method `render_to_string’

Tagged with: , ,
Posted in Html, JQuery, Ruby Little Codes
StackOverFlow
Categories
Archives