1

I used the following code to create a button for my plug-in:

retVal.Append(Forms.SubmitButton(api.AddPluginPrefix("btnRefresh"), "Refresh"));

It generated this HTML:

<input type="submit" value="Refresh" 
       class="dlgButton " chotkey="o" 
       name="P20_btnRefresh"/>

It would be nice if you could also set the ID attribute of the element to make it easier to reference in client-side scripts. Even if it was the same as the name attribute.

I've discovered that I can select the element in JQUERY using this syntax:

$([name$='P20_btnRefresh'])

But it doesn't seem as clean as it would with an ID.

$('#P20_btnRefresh')
flag

1 Answer

2

All those Forms methods can take a dictionary as the final parameter, which lets you set attributes. In your case you'd do something like this:

Hashtable attrs = new Hashtable();
attrs["id"] = "myid";
retVal.Append(Forms.SubmitButton(api.AddPluginPrefix("btnRefresh"), "Refresh", attrs));
link|flag
Great answer. Thanks! – JohnFx Oct 2 2009 at 23:22

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.