最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - YUI Checkbox Button - retrieving the checked value - Stack Overflow

programmeradmin6浏览0评论

(I've tried posting this on YUI message group but without any luck)

Can anyone tell me how to retrieve the checked state of a yui Button? I've tried by creating the Button in code, which is then outputted as a HTML button but this only changes the title attribute.

When I use checkboxes instead, none of the checkboxes are checked (when iterating through them with jQuery).

Is there an easier way of doing it? Say with the 3.0 Node API, or Element?

EDIT: To clarify how this problem came about, I'm using the YUI ASP.NET controls. They add controls to the page like this

Sys.Application.add_init(function() {    $create(YUIAspNet.Button, {"ButtonID":"yuiMyButton_btn","ButtonName":"yuiMyButton$btn","TabIndex":0,"ButtonType":"checkbox","Text":"Technology"}, null, null, $get("yuiMyButton"));});

So as you can see, finding all buttons is not as simple as I'd like it to have been.

(I've tried posting this on YUI message group but without any luck)

Can anyone tell me how to retrieve the checked state of a yui Button? I've tried by creating the Button in code, which is then outputted as a HTML button but this only changes the title attribute.

When I use checkboxes instead, none of the checkboxes are checked (when iterating through them with jQuery).

Is there an easier way of doing it? Say with the 3.0 Node API, or Element?

EDIT: To clarify how this problem came about, I'm using the YUI ASP.NET controls. They add controls to the page like this

Sys.Application.add_init(function() {    $create(YUIAspNet.Button, {"ButtonID":"yuiMyButton_btn","ButtonName":"yuiMyButton$btn","TabIndex":0,"ButtonType":"checkbox","Text":"Technology"}, null, null, $get("yuiMyButton"));});

So as you can see, finding all buttons is not as simple as I'd like it to have been.

Share Improve this question edited Jun 16, 2015 at 14:27 Dylan Corriveau 2,5554 gold badges30 silver badges36 bronze badges asked Jan 19, 2009 at 14:37 Chris SChris S 65.5k53 gold badges224 silver badges240 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Sorry are you talking about checkbox buttons? Use:

myButton.get("checked")

where myButton is an instance of YAHOO.widget.Button.

Chris, I am the starter of YUI ASP.NET project. I watch the YUI mailing list regularly, I must of missed your question.

I have a more general answer for you and anyone else having the problem and ending up reading this, not just for checkbox button, but for all controls.

On the client, you can have access to the YUI object by calling the .get_YUIControl() method on the custom wrapper client object, then you have the control over the original YUI object. The YUI documentation is very good, and you can find a good description for what you'd like to acplish.

发布评论

评论列表(0)

  1. 暂无评论