-
August 1st, 2023, 07:15 AM
#1
Unable to bind onclick event to an anchor tag
Hi,
I have an issue and stuck with it for quite sometime now. Can someone please guide me. I need to bind a onclick event to an anchor element dynamically, I checked the examples that Giuseppe's pointed out but still no luck. Let's say I have my html code like :
<td id="msg" class="revSubject highlight" style="text-align:left;" nowrap="">
<a href="#" data-source="lightstreamer" data-field="click" data-update="onclick">
<span><div data-source="lightstreamer" data-field="msg"></div></span>
</a>
</td>
In my js code I did set node types as well :
grid.setNodeTypes(["div","tr","a"]);
From my java adapter I'm send the click field :
map.put("click", "getCCSInboxMsgBody(109539,0,"SysTrdInbox &quo t;return false;");
but still the event is not getting attached to the <a> element, I'm using DynaGrid with ADD command.
-
August 1st, 2023, 10:05 AM
#2
Hi Krishna Teja K,
The snippet of code you attached seems correct to me and the onclick should be actually updated.
Could you please try to trace if indeed your page receives the update with the click field? You could add a listener to your subscription, something like this:
dynaGrid.addListener({
onVisualUpdate: function(key,info,domNode) {
if (info == null) {
return;
}
info.forEachChangedField(tracefieldvalue);
}
})
Regards,
Giuseppe
-
August 1st, 2023, 02:58 PM
#3
Hi Giuseppe,
Thanks for the quick reply, yes you are correct the "click" field is not coming up even though I've added it to the java smart update arg map.
-
August 1st, 2023, 03:09 PM
#4
Hi Krishna Teja K,
Ok, so we need to understand why your client don't receive the "click" field as expected.
Please could you post here the code lines the client use to subscribe?
Are you able to access the server log? In that case we could also take advantage of particular log settings.
Regards,
Giuseppe
-
August 1st, 2023, 03:16 PM
#5
I just added a debugger and could see that the click field is present in "info.jJw" but not in "info.GVV", can you please explain what's happening here:
I don't see the field even in this function: info.forEachChangedField(...)
-
August 1st, 2023, 03:18 PM
#6
Here's my client subscription code:
function linkToLS_Signal(lsTable,user_id,trdPlanStr,trdPlan SigType) {
console.log("In linkToLS_Signal");
require(["LightstreamerClient","Subscription","DynaGrid "],function(LightstreamerClient, Subscription, DynaGrid) {
var client = new LightstreamerClient("https://push.finodex.com","TEST");
client.connectionSharing.enableSharing("FdxShare", "ATTACH","CREATE");
client.connect();
var grid = new DynaGrid(lsTable, true);
grid.setNodeTypes(["div","tr","a"]);
grid.setAutoCleanBehavior(true,false);
grid.addListener({
onVisualUpdate: function(key, info, domNode) {
if (info == null) {
return;
}
var myField;
info.forEachChangedField(function (field, value) {
myField = field;
info.setCellAttribute(myField, greenColor, null,"backgroundColor");
info.setCellAttribute(myField, hotTxtCol, null,"color");
});
}
});
var subsList = ['trsignal_'+user_id+'_'+trdPlanStr+'_'+trdPlanSigT ype];
var fieldsList = ['command', 'key', 'date', 'time', 'channel', 'msg', 'msgid'];
subscription = new Subscription("COMMAND", subsList, fieldsList);
//subscription.setRequestedSnapshot("no");
subscription.addListener(grid);
client.subscribe(subscription);
});
}
-
August 1st, 2023, 03:22 PM
#7
Hi Krishna Teja K,
You need to add 'click' in the fieldsList.
Regards,
Giuseppe
-
August 1st, 2023, 03:54 PM
#8
Thanks a lot, I overlooked it!
-
August 1st, 2023, 04:01 PM
#9
Giuseppe, we have another requirement in our project where we need to clear the messages(rows) from the table which are currently pushed already let's say when user changes the filter or clicks a button. Right now even though the screen is refreshed the old messages are still present maybe due to the snapshot that it carries.
I was able to clear the snapshot from the server by using the ItemEventListener's -> clearSnapshot(...) method but is there any other way that we can clear the snapshot from the client itself when the user performs certain action.
-
August 1st, 2023, 04:28 PM
#10
Hi Krishna Teja K,
Sorry but your scenario is not totally clear to me, but have you tried to use removeRow?
Regards,
Giuseppe
Similar Threads
-
By kid_119k in forum Client SDKs
Replies: 6
Last Post: November 26th, 2012, 02:55 AM
-
By tsezuu in forum Client SDKs
Replies: 2
Last Post: November 24th, 2011, 03:09 AM
-
By dimitarn in forum Client SDKs
Replies: 6
Last Post: March 26th, 2010, 04:09 PM
-
By ningping in forum Client SDKs
Replies: 1
Last Post: August 6th, 2008, 11:05 AM
-
By eduramires in forum Client SDKs
Replies: 3
Last Post: February 4th, 2008, 09:14 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 08:19 AM.
Bookmarks