How can I find a custom dropdown object in javascript? I have looked everywhere and am missing something very simple.
For example, in this code, I can see that I have the ID of the control but I cannot figure out how to get the actual object so I can set the text value. :
function WebEditor_BeforeAction(oEditor, actID, oEvent, p4, p5, p6, p7, p8, act) {
if (act == 'texthtml') { //var btn = oEditor.Toolbar.; alert("Drodpown: " +dd.Key + ", " + oEvent.Key + ", " + p4.Key + ", " + p5 + ", " + p6 + ", " + p7 + ", " + p8 + ", " + act); if (edit) edit._showHtml(!edit._html); iged_closePop(); }
I have tried loads of dfifferent approaches and always get a null value. Let's pretend that the dropdown control is called ddMyItem as an example
Hello wireplay ,
Thank you for posting in our forum.
Are you creating your own ToolbarDropDown?In that case, depending on what action you take on it ,the passed arguments will be different.For example if you have the following custom drop down:
<ighedit:ToolbarDropDown runat="server" ClientIDMode="Predictable" Type="Custom"
DropDownHeight="200px" DropDownWidth="150px" Height="20px" Key="MyActionKey" Title="CUSTOM"
Width="100px">
<Items>
<ighedit:ToolbarDropDownItem runat="server" Act="Greeting" ClientIDMode="Predictable" />
</Items>
</ighedit:ToolbarDropDown>
If you open the drop down then the act will be “pop” and the p4 argument will contain your editor’s client id.If you select a value from the drop down the act will be “MyActionKey”. Then p4 will be the selected item.
Once you have the client id of the editor (from p4 on the correct act) then you could get the element by id:
var editor = document.getElementById(p4);
Let me know if you have any questions or concerns on the matter.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Thanks Maya. I had tried this before and it throws a null value. That is why I am confused.
if (act == 'btnsubmit') { var btn = document.getElementById("<%=btnSubmitPost.ClientID%>"); if (btn != null) { btn.click(); event.keyCode = 0; } } if (act == 'texthtml') { //var btn = oEditor.Toolbar.; alert("Made It!"); var tool = document.getElementById(p4); if (tool == null) alert("Null Value"); else alert("Tool id: " + tool); if (edit) edit._showHtml(!edit._html); iged_closePop(); } }
More details:
<ighedit:ToolbarDropDown runat="server" ClientIDMode="Predictable" Key="TextHtml" Type="Custom" Width="50px" Title="Text"> <Items> <ighedit:ToolbarDropDownItem runat="server" Text="Text" Value="Text" Act="Greeting" ClientIDMode="Predictable" /> <ighedit:ToolbarDropDownItem runat="server" Text="HTML" Value="Text" Act="Greeting" ClientIDMode="Predictable" /> </Items></ighedit:ToolbarDropDown>
Thanks a lot. Your first part was the approach I took and it worked fine.
In that case when the act is 'texthtml' the p4 parameter will be the selected item not the provider’s client id.You can get the editor on the act “pop”. Then p4 will be the client id of the editor.If you want to get the editor during the texthtml act (on selection of the drop down) then you could get the editor from the selected item’s parent. For example:
function WebHtmlEditor1_BeforeAction(oEditor, actID, oEvent, p4, p5, p6, p7, p8, act) {
if (act == 'texthtml') {
var editor = p4.parentElement.parentElement.parentElement.parentElement;
}
I’m attaching a sample for your reference. Let me know if you have any questions.