I'm creating html elements with a js code and next i should query those elements to connect them with some svg line plugin. Thing is, one is inside the origin element and the other one is not.
what happens with those duplicate ids? is jquery able to find the second one or not?
function paintIds(table){
$.post('findIds', {
chain : table // this is the parameter
}, function(response) {
var vec = response.split(","); // the response is a comma separated list of table fields, so i turn it into an array
vec.forEach(function(c){
// paint fields on screen
$('#'+'DW'+table).append('<span class="key" id="sn'+c+'">'+c+'</span>');
});
$('#'+'DW'+table).append('<hr>'); put an ht in the end of the list
});
}
so this happens
I can have 2 elements called ID_GAL. Then i go and try to connect those elements with another function, but sometimes element ids repeat because they are fields names inside some tables..the ids format goes like #snFIELD_ID
target = $('#sn'+elem).eq(0);
if($('#sn'+elem,'#'+c.replace(/\./g, '')).length == 1) {
console.log('target inside origin')
target= $('#sn'+elem).eq(1); // if i find that one is inside another, then i change my target var to the second
}else{
console.log('target is not inside origin')
}
console.log(target.id + '==> #sn' + elem);
var connex = jQuery('#'+c.replace(/\./g, '')).connections({ to: target,'class': 'lineas' });
setInterval(function() {
connex.connections('update');
}, 200);
So, thing is, because they are sometimes duplicated i cannot draw my line because the element is inside the origin. In the example DW.DIM GAL > ID_GAL should connect with DW.DIM_ART > ID_GAL
How can i find my second id to connect?