I want to dynamically populate a dropdownlist using jQuery. I am trying to call a controllers action but I don't know how with the collection_select object. I have tried the :input_html but the controller action is never called. I receive a parsing error in my javascript debugger because javascript is trying to parse the whole view page.
Code in View:
<div id="ssmodels">
<%= collection_select :ssmodel, :ssmodel, @ssmodels, :id, :name, :input_html => {:rel => "/phrases/update_submodel_select" } %>
</div>
<div id="ssmodel_sssubmodel">
<%= collection_select :ssmodel, :sssubmodel, @sssubmodels, :id, :name %>
</div>
Javascript in Application.js:
$.fn.subSelectWithAjax = function() {
var that = this;
this.change(function() {
$.post(that.attr('rel'), {id: that.val()}, null, "script");
return false;
})
};
$(document).ready(function(){$("#ssmodels").subSelectWithAjax();
})
$(document).ready(function(){$("#ssmodel_sssubmodel").subSelectWithAjax();
})
Please help.