I have this ruby method:
def something(sometext, jsvariable, rubyobject)
return HTMLOBJECT
end
And I would like to call this method like this in a javascript function:
$("#someid").append('<% something("sometext", '/jsvar/', rubyobject) %>');
Its not working.I don't know how to call this method from a javascript function with proper
formatting of the variables. I don't really know the exact syntax for it.
Any help is much appreciated.
UPDATE: This is what I'm trying to do
function somejsfunc(){
$.ajax({
url: "/app/SomeController/someMethod",
data: {'something': something }
success: function(data){
var $response1 = $(data);
jsvar = $response1.find('#anotherselector').text();
$("#someid").append('<% something("sometext", '/jsvar/', @rubyobject) %>');
}
});
}
Please Note
def something
is a generic method which returns a HTML DOM element based on these parameters,along with other data passed into it.Thanks.
somethingmethod. In the Ajax-call you have to specify that rout with the desired parameters. These will end up in your controller method in the regularparamshash and you would have to continue from there.