Make a value clickable
Make a value clickable
Hi, I'm using Datatables. I get a values with AJAX, and show it. One of this fields are telephone number, and I'd like to make it clickable.
Now I have it works this way:
This works, in tel_companie, tel_direct, mobile_ofi fields I can see a blue link number, and I can clicked.
The problem I have is when in one field I have two numbers.
I received the number via AJAX like this:
number1<br/>number2 and show in datatables in two rows inside the same row, like the photo.
When I click in one of thats numbers, I get number1<br/>number2<br/>...
I cannot know the number click.
How can I send only the number click?
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
The best way to do that would be to use
columns.render- see example here. You would need to also parse the string, strip out the
<br>tags, and generate links on both the numbers - but that would all be done within the
Hi, thanks for answer to me..
I've tried that, this way:
But when I click the phone number, always return me number1<br/>number2<br/>..
What are I doing wrong?
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Hi, sorry for delay...
I've tried to make a sample, but I don't know how is it..
I have this:
In "telefonos", I don¡t konw how show you, I have 123456<br/>98765<br/>
I've tried to separate each number in a new line, but no works..
And when I clicked in the number, I get: 123456<br/>98765<br/>
I don't get click number.
I have this when I click the number:
What am I make wrong??
I'm not clear what you're trying to do - that click code isn't in the test case provided. Please can you provide a test case reproducing the issue you want help, with steps on how to reproduce, and explaining what you would prefer to happen instead,
I'm not clear what the issue is but this block of code doesn't seem correct:
You have a
returnstatement inside the for loop. Are wanting something like this?
oData[ i ]in line 3.
If you still need help please update the test case to show what you have so we can see the problem and offer suggestions.
OK, sorry, I didn't know how can I shared you the exmple, now yes, I think....
I have this:
In that example, you can see 4 columns in the number three, I have phones number. In the first row I get the phone numbers like 12345<br/>9876<br/>, and with render I can put in 2, 3.... lines, perfect!! thanks...
Now the problem.
I've made that phone numbers like a link, when I click that link, is where I hace the problem.
If I click in the second row, I get 12345, perfect.
If I click in the firts row, It doesn't matter if I click in the first number or the secodn, I always get 12345<br/>9876<br/>.
The question is, how can I get the number clicked? If I click in the first number, get 12345..
Is it possible?
P.S: I don't know Why don't work when I click in the number, in this example, but in my code works..
There were two issues with the test case. First this error:
Had to assign
Next is the table ID needs to be prefixed with
#for the click event handler, like this:
Use standard jQuery methods to get the attributes of the element clicked, like this:
Here is the updated test case:
Sorry, copy/paste fails...
Perfect!! Works great!!
Thank you so much..