jQuery change href attribute

jQuery change href attribute

Hi all,

we'd like to change the href attribute of a link with jQuery.
We use this:

var hrefje = $(""#" + linkPopUp.Id + """).href;
hrefje = hrefje.replace(
""EventId=0"",""EventId="" + data[0] ); 
""#" + linkPopUp.Id + """).attr('href', hrefje) ;

It errors out after setting the attribute (last line)
We've been digging around on internet but can't find why it is not working. We seem to use the right syntax

Anybody any clue ?

Does it work with simply $(""#" + linkPopUp.Id + """).attr('href', 'foo.aspx') ;

It might be an issue with what type hrefje is.

wouldn't it better to do something more like

var hrefje = $(""#" + linkPopUp.Id + """).attr('href');
hrefje = hrefje.replace(
""EventId=0"",""EventId="" + data[0] ); 
""#" + linkPopUp.Id + """).attr('href', hrefje) ;

Nope it does not work...
Seems the OSJS file replaces the $ with something.
Hi Joop,

just to make sure, are you importing the jQuery .js? by doing something like <script src='http://code.jquery.com/jquery-latest.js'></script> if not you should use the "Outsystems jQuery" by replacing all $ with osjs.

let us know if this was the problem!

Miguel Antunes

I tried incoporate the JS as resource (deploy to targetdir) using AddJavascriptTag or include the JS a an expression in the screen.
Neither does work. The only thing what works is add ALL the content of the JS files I want to use in the webscreen javascript ...
This is also the way the RichWidgets are setup ... all in webblock javascript properties

It also has to do with the order the platform generates the HEAD section.
It SHOULD first generate all the OS stuff and then the AddJavascript and AddStyleSheet Tags.
That way one can add own JS files which are necessary in a webscreen/block

See also this post http://www.outsystems.com/NetworkForums/ViewTopic.aspx?Topic=RE%3a-How-to-use-JQuery-in-the-web-screen-#Post4