i currently try to call a javascript method with link_to_function.
<%= link_to_function( r.cls.to_s.split("#").last ,
"loadDetails('#{Base64.encode64(r.cls.to_s).strip}');" )%>
The problem is i get a JS error:
Uncaught SyntaxError: Unexpected token ILLEGAL
I assume this happens because rails puts some line breaks into my code:
onclick="loadDetails('aHR0cDovL3d3dy5vd2wtb250b2xvZ2llcy5jb20vT250b2xvZ3kxMzUxNzAy
NTA5Lm93bCNjMzM=');; return false;"
I would like that link_to_funktion prints out linke-break-free output.
Do you know how to archieve this?
PS:
When i escape javascript it still returns:
Uncaught SyntaxError: Unexpected token ILLEGAL
Related
I have recently installed brakeman and ran the gem on my system. One error it is picking up is in relation to what I believe is a parenthesis.
The line of code it is picking an error up on is:
%p=link_to("Click here", url_for(only_path: false, host: ConfigSetting.get("FORGET_PASSWORD_HOST_PREFIX","localhost"), account_new_passwd_reset_path(key: #guid)))
I have recently updated syntax which required an extra parenthesis after the 'account_new_passwd_path'. I believe this is the issue but I cannot understand why.
The outdated code I had was:
%p=link_to("Click here", url_for(:only_path=>false, :host=>ConfigSetting.get("FORGET_PASSWORD_HOST_PREFIX","localhost"), :controller=>:account, :action=>:new_passwd_reset, :key=>#guid))
As you can see in terms of the routing it is the biggest change around the key #guid area.
Any ideas?
The error I am receiving is 'Error: app/views/passwd_reset_mailer/password_reset.haml:3 :: parse error on value ")" (tRPAREN) Could not parse app/views/passwd_reset_mailer/password_reset.haml'
The problem is the order of arguments. Keyword arguments need to be at the end of the argument list. But then there is another issue that using a url helper together with url_for doesn't really makes sense.
Just change:
%p=link_to(
"Click here",
url_for(
only_path: false,
host: ConfigSetting.get("FORGET_PASSWORD_HOST_PREFIX","localhost"),
account_new_passwd_reset_path(key: #guid)
)
)
to
%p=link_to(
"Click here",
account_new_passwd_reset_url(
host: ConfigSetting.get("FORGET_PASSWORD_HOST_PREFIX","localhost"),
key: #guid
)
)
Please note the _url instead of the _path suffix, which test Rails to build a full URL including the hostname.
Chrome:
VM17:4 Uncaught SyntaxError: Unexpected identifier
at processResponse (rails-ujs.js:283)
at rails-ujs.js:196
at XMLHttpRequest.xhr.onreadystatechange (rails-ujs.js:264)
view x.js.erb
$(#new).hide();
You need to quote the argument passed to jQuery to make it a string:
$('#new').hide();
I'm playing with lua, using the following link: https://www.lua.org/pil/8.html and got confused about this syntax error.
So, the file foo.lua is as the following:
function foo (x)
print(x)
end
Then,
~$ f = loadfile("foo.lua")
bash: syntax error near unexpected token `('
Any comments are greatly appreciated.
I am getting a strange SytaxError with JSLint
I have a file with no code except:
var a = function(){
if(isChecked())
{ }
};
And I get this error:
SyntaxError: missing ; before statement
if(isChecked())
......^
I made another file with only if(Math.Round()) { alert('here');}, and I get
SyntaxError: missing ; before statement
if(Math.Round()) { alert('here');}
....................^
I built jslint for Ubuntu and the error does not appear on the online lint site. I just need to ignore this error, but /jsl:ignore/ does not work (maybe because it is a syntax error.
It appears that there is some kind of encoding error. If I write this code myself, there is no error, but if the code is copy and pasted from a document which had an error, then these errors ensue.
The solution is to re-type the code and save the file.
So, I've got bluecloth installed and I'm trying to use the Control.TextArea javascript WYSIWYG editor.
Anyways, I followed the tutorial on the page and when I load the corresponding view, I get an error:
uncaught exception: Control.TextArea requires Object.Event to be loaded.
This comes from Control.TextArea js file.
Any ideas? Thanks