Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 4 characters in body
Source Link
Dane O'Connor
  • 77.9k
  • 41
  • 122
  • 174

You can modify the url for your link in the click event. You just have to turn your url into something that's easy to parse. Something like the following;

foreach ($exploredArtistBands as $band) { echo '<a href="/notification/invite/{id}/' . $band['band_id'] . '">Join to ' . $band['name'] . '</a><br />'; } 

So you end up with a link like:

href="/notification/invite/{id}/band_id" 

Now in your click handler, replace {id} with the id from the button.

$('.invite').click(function(){ var id = $(this).attr('button-id'); var oldUrlurl = $(this).attr("href"); $(this).attr("href", oldUrlurl.replace('{id}', id)); }); 

The click event will continue to bubble, but with a new url. This will ultimately direct your browser to the right place. This approach smells to me, but it works.

You can modify the url for your link in the click event. You just have to turn your url into something that's easy to parse. Something like the following;

foreach ($exploredArtistBands as $band) { echo '<a href="/notification/invite/{id}/' . $band['band_id'] . '">Join to ' . $band['name'] . '</a><br />'; } 

So you end up with a link like:

href="/notification/invite/{id}/band_id" 

Now in your click handler, replace {id} with the id from the button.

$('.invite').click(function(){ var id = $(this).attr('button-id'); var oldUrl = $(this).attr("href"); $(this).attr("href", oldUrl.replace('{id}', id)); }); 

The click event will continue to bubble, but with a new url. This will ultimately direct your browser to the right place. This approach smells to me, but it works.

You can modify the url for your link in the click event. You just have to turn your url into something that's easy to parse. Something like the following;

foreach ($exploredArtistBands as $band) { echo '<a href="/notification/invite/{id}/' . $band['band_id'] . '">Join to ' . $band['name'] . '</a><br />'; } 

So you end up with a link like:

href="/notification/invite/{id}/band_id" 

Now in your click handler, replace {id} with the id from the button.

$('.invite').click(function(){ var id = $(this).attr('button-id'); var url = $(this).attr("href"); $(this).attr("href", url.replace('{id}', id)); }); 

The click event will continue to bubble, but with a new url. This will ultimately direct your browser to the right place. This approach smells to me, but it works.

Source Link
Dane O'Connor
  • 77.9k
  • 41
  • 122
  • 174

You can modify the url for your link in the click event. You just have to turn your url into something that's easy to parse. Something like the following;

foreach ($exploredArtistBands as $band) { echo '<a href="/notification/invite/{id}/' . $band['band_id'] . '">Join to ' . $band['name'] . '</a><br />'; } 

So you end up with a link like:

href="/notification/invite/{id}/band_id" 

Now in your click handler, replace {id} with the id from the button.

$('.invite').click(function(){ var id = $(this).attr('button-id'); var oldUrl = $(this).attr("href"); $(this).attr("href", oldUrl.replace('{id}', id)); }); 

The click event will continue to bubble, but with a new url. This will ultimately direct your browser to the right place. This approach smells to me, but it works.