Support

Account

Home Forums Backend Issues (wp-admin) Updating Field Using Javascript API

Unread

Updating Field Using Javascript API

  • Alright I am trying to update the value of a range slider field using the javascript api. This is what I have so far. Basically this grabs the width of the new column and puts it into a slider that has the class column width. It gets the percentage and everything just fine but after that I tried to update the slider so that is reflects the new percentage in the slider but it doesn’t change. any help is appreciated.

    acf.addAction('append_field/type=range', function(field){
    		
    	if(field.$el.hasClass('column-width')){
    	/* Gets column width put in through acf */
    	var column_width = field.$el.closest('.theme-column').css( "width").replace("px", "");
    	/* Gets layout class from acf backend code */
    	var layout_width = field.$el.closest('.layout').css('width').replace("px", "");
    			
    	/* Find the width of the new column and put it in the 12 grid system */
    	var column_percent = column_width/layout_width;
    
    			
    	/* Assign grid width to column width range value */
    			
    	field.$el.val(column_percent);
    	}
    				  
    });
Viewing 1 post (of 1 total)

The topic ‘Updating Field Using Javascript API’ is closed to new replies.