Tuesday 9 January 2018

Iframe height adjustment on page load

function getDocHeight(doc) {  doc = doc || document;  var body = doc.body, html = doc.documentElement;  var height = Math.max( body.scrollHeight, body.offsetHeight,      html.clientHeight, html.scrollHeight, html.offsetHeight );  return height;}
function setIframeHeight(id) {  var ifrm = document.getElementById(id);  var doc = ifrm.contentDocument? ifrm.contentDocument:    ifrm.contentWindow.document;  ifrm.style.visibility = 'hidden';  ifrm.style.height = "10px"; // reset to minimal height ...  // IE opt. for bing/msn needs a bit added or scrollbar appears  ifrm.style.height = getDocHeight( doc ) + 4 + "px";  ifrm.style.visibility = 'visible';}

Friday 25 August 2017

Fetch Full Url from String by Javascript

 
//Remove Html code from string 
var textString = code.replace(/<\/?[^>]+(>|$)/g, " ").replace(/^(&nbsp;|nbsp;)+/g, '').trim(); //Match full url and generate a array
var urls = textString.match(/\b(http(s)?(:\/\/))?(www.)?[a-zA-Z0-9-_.]+(.[a-zA-Z0-9]{2,}).*?(\.\w+)([-a-zA-Z0-9:%_+.~#?&\/\/=]*)/ig);

//Remove content before http
var url =  /http(.+)/.exec(urls[0])[0];

Wednesday 15 March 2017

Slider

slick
 
 
http://amazingslider.com 

Auto suggest in rails for fields it so simple by help of data-autocomplete parameter

 
Define data-autocomplete field in text field and then path of the function with parameters: 
 
=f.text_field :user_search,"data-autocomplete" => autocomplete_user_name_path(:user_type=>"Admin")
 
 
Controller Action:
 
def autocomplete_institution_name
  term = params[:term]
  user_type = params[:user_type]
  
  users = User.where('name LIKE ? AND user_type = ?', "%#{term}%",user_type).order(:name).all 
  render :json => users.map { |user| {:id => user.id, :label => user.name, :value => user.name} }
end 
 

Thursday 2 March 2017

Ruby On Rails Form with Ajax by remote => true

<<<==============================Ruby Ajax Form Submitting Syntax =======================>>> 
 
=form_for @modelObject, :remote => true,:html => {:'data-type' => 'json',:onSubmit=>"checkform()"}
,:url => url_path([@paramsinUrl]) do |f|
 
 
 
 
<<<<=======================================Controller==============================>
 
def create
 @modelObject =  ModelObjectClass.new(params['params_name']) 
 respond_to do |format|
   if @modelObject.save
       format.html { redirect_to :back }
       format.json { render :json => {:status=>"success",:message=>'Added Sucessfully.'} } 
   else
     format.html { redirect_to :back }
     format.json { render :json => {:status=>"error",:message=>'Error Message.'} } 
   end 
 end 
 
end 
 
 
 
<<<<==================================Javascript======================================>
 
$("#form_id").live("ajax:beforeSend", function(e, xhr, settings) {
  

});
$("#new_manual_air_booking").live("ajax:success", function(e, data, status, xhr) {
   alert("Added");
   render_time_slot(DI.day_wrapper_id,DI.day_date,DI.trip_id);
   $("#daily_itinerary_event_model").html('');

}).live("ajax:error", function(e, xhr, status, error) {
    alert("Error");
});  

 


=======================================OR================================================ 
 live => on

Instead of live you can use on because live deprecated few year back, syntax for using on is:
 
$(document).on('ajax:beforeSend','#form_id',function(e, xhr, settings) {
  

}); 
 
 Instead of document you can wright parent element id of element which we are going to target.
 

Thursday 23 February 2017

Ruby on Rails Developer need to have aware about


RoR experience in 3.x, 4.x, 5 beta
- Ruby 2.x
- Rspec, Mocha, Cucumber
- Postgres, RDS
- Passenger, Puma
- AngularJS/NodeJS
- Redis, SQS
-Rails caching 

RSpec and Resque
Demonstrated strengths for JAVA 7 and above, Core Java, Advance Java, Jersey Framework, JMS, JSON, XML, 
 
RESTFUL and SOAP web services