jQWidgets Forums
jQuery UI Widgets › Forums › ASP .NET MVC › Creating JQXCombobox dynamically with events
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 7 years, 7 months ago.
-
Author
-
I am developing an dynamic web application.
i build an jqxcombo box control successfully to dom. by creating dynamic id to it .
Now i want to create an change event for dynamically created combobox.if we know id of that control we write on change event directly but here i want to build that change event dynamically .
var dynamicid=’combobox1′; //this id coming from database
$(“#divcontrols”).append(“<div id='” + dynamicid + “‘></div>”)
then i prepared my source
then created control
$(“#” + dynamicid ).jqxComboBox({ selectedIndex: 0, source: dataAdapter, displayMember: “display”, valueMember: “value”, height: ’25px’ });
now i want to create change event for thisfor me control is created successfully with data into ui. only problem i am not able to create event for that.
if i know id directly i can write change event for that.but the thing is id will come dynamically and that to i don’t know how many combox control will be rendered into ui that is based on databse if i get 5 id’s from database i need to create 5 comboboxes and respected change evennts. It is not happening now i am creating controls but not events.Thanks in advance
Hi balachandra,
If you select this with jQuery or something else, use the jQuery’s on method or the Javascript’s addEventListener to add an event handler. As you created the control with jQuery as far as I see, use it’s ID to select the HTML Element after you created the ComboBox and do that $(“#….).on(‘change’, function(event) {});
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
Thanks for your reply.The answer which you given is perfect when we use normal html controls with jquery.
i already know creating event dynamically in jquery previously my dynamic application with dynamic html controls and dynamic jquery events for all my controls like textbox,dropdown etc..Now i am converting html controls to Jqwidgets controls,i started with jqxcombobox so i am expecting dynamic jqwidgets events for all operations with all jqwidgets controls.
I think you got my point.
Thanks in advance.
Hi balachandra,
The concept is the same. As soon as you add it to the DOM, bind to the event.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.