I have a problem with a button that I want it to redirect to another page, I used the location.href but it didn’t work also I’ve used the jQuery method $(location).attr('href','url') and nothing happend either to make it more clear
the button goes like this:
<input type="button" value="New Project" onclick="createDiscoveryProject()"/>
where the method createDiscoveryProject is like this:
function createDiscoveryProject(){$(location).attr('href',[@spring.url '/myPage'])}
now when I click on the button nothing happen even when I ‘ve added alert method inside the createDiscoveryProject no alert pops, finally I want to add that the JavaScript method is in the template ftl file while the button is in another ftl file. any help?
Since you are already using jQuery why don’t you bind the function on document ready to the button. Don’t get me wrong, the way you’re doing is should totally work, but since you are saying that even an alert isn’t working there might be another js error in your code so maybe this way you will work around it.
So: