Pergunta

I've got a column with a URL set to execute a function on click, but when I click it, it goes adds a # to the end of the url instead of executing the function. The URL is registering as:

<a onclick='OpenLandLRegistration(1)' href='#'>Register</a>  

Here's the javascript code:

function OpenLandLRegistration(event_id){

var eventurl ="/Lists/Events/DispForm.aspx?ID="+meeting_id;

 var options = {

      url:"/Lists/Attendees/Item/newifs.aspx?List=%7B9E2217C5%2DE878%2D406D%2DB25A%2D2FA7EAADFC17%7D&meeting_id="+meeting_id,

      width: 750,

      height: 600,

      dialogReturnValueCallback: DialogCallback

 };

//SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
window.open(eventurl);

}

function DialogCallback(dialogResult, returnValue){  }

EDIT:: Here is a working example of what I'm trying to do: link

The javascript converts the link to html and the executes the function on click.

Foi útil?

Solução

To prevent a link from firing, just add a return false; at the end of your OpenLandLRegistration() function.

Also the problem could be coming from the fact that in this example, at least, the meeting_id variable you're attempting concatenate with "/Lists/Events/DispForm.aspx?ID=" is undefined, so it'll throw a reference error and exit immediately.

Also worth noting that nothing is happening with options either, beyond it getting defined.

Have you heard of Firebug for Firefox? It's an excellent debugger for javascript that can really help you step through bugs as you work through things like this.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top