开发者

Drupal hiding a file upload button on a form but showing it something is clicked

I am using CCK on a custom node type. I have created a field that is a file upload. By default I do not want to show this field in the form so in my CSS I have:

#edit-field-name-doc-0-upload-wrapper{
    display:none;
}

When an option is selected from a drop down/select list I want to show the field.

I had the following jquery.

$('#edit-field-name-doc-0-upload-wrapper').show();

This shows the Title of the field but not the file upload.开发者_运维知识库

I think the reason for this is that the file option fields are inserted into the page after my jquery has run. It is not in the jquery dom so my show event is not having any effect.

What can I do to solve this?


I just tried the following in a CCK based node that has a select box and a file upload (via filefield 6.x-3.7). The select has id "edit-field-chooseone-value" and the wrapper for the upload field has id "edit-field-hiddenupload-0-ahah-wrapper". The things you might be missing are making sure that the code doesn't run till the dom is loaded or using the change event on the drop down.

$(function(){
  $('#edit-field-chooseone-value').change(function(){
    $('#edit-field-hiddenupload-0-ahah-wrapper').show();
  });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜