caching - rails controller action not being called -


the problem i'm running deals rendering partial. have link should updated after user puts text in text field. first time works fine. user types in text, link gets updated , when link clicked partial rendered correct information. when text changed link gets update new parameters pass action when link clicked still renders old partial , no call corresponding action made. here view code:

label.control-label for="color_servers" colors         .controls           input.input-xxlarge type="text" name="colors" id="project_colors" placeholder="comma separated colors" onblur="getcolors(this)"           data-toggle="modal" id="color_target" href="#" data-target="#color_modal" (show colors)  .modal.hide#color_modal   .modal-header     button.close type="button" data-dismiss="modal" aria-hidden="true" ×     h3 color list   .modal-body   .modal-footer     a.btn href="#" data-dismiss="modal" aria-hidden="true" close 

and partial rendering:

ul     - color in @colors         li #{color} 

i'm displaying partial information in lightbox type display. here javascript code onblur event of text field:

function getcolors(elem){       if(elem.value.trim()){         $.ajax({           url: "/project/check_colors",           type: "get",           datatype: "json",           data:{             colors: elem.value           },           success: function(data){             $('#color_target').attr('href','/project/show_colors?colors=' + data.color_list)             console.log(document.getelementbyid("color_target").href)             console.log(data.input)             console.log(data.color_list)           }         });       }     } 

so in javascript code when @ output of href attribute in console, shows correct link. , here controller code:

def check_colors     colors = params[:colors].gsub(/\s+/, "").gsub(/,+/,",")     colors = colors.chomp(",")     color_list = color.expand_colorset(colors).map(&:fullname)     render 'index', :json => {                                  :servers => color_list,                                 :input => colors                                  }   end    def show_colors     colors_string = params[:colors]     @colors = colors_string.split(",")     puts @colors     render partial: 'color_list'   end 

the color_list variable array of colors send in order update link with. know show_colors action gets called called first time because @colors variable's value printed in terminal when update text in textfield , click on link again action not being called though link gets updated because nothing printed in terminal. seems if partial being cached, if problem how can prevent that. when try render partial full fledged view rather partial, action called correctly every time , renders correct information after changing text field contents, when lightbox functionality not work correctly. appreciated, thank you.

hi guys interested figured out. kind of hacky works me. added piece of code in javascript outside of functions, , cleared cached ajax.

$('body').on('hidden', '.modal', function(){$(this).removedata('modal');});

hopefully save time in future.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -