我的脚本出了什么问题。应该打开对话框表单,是吗?
我的HTML:
<section id="music_features">
<header>
<hgroup>
<h1>Your Playlist</h1>
<p>Up to only 3 files allowed for beta version</p>
</hgroup>
</header>
<p id="song_upload_menu"><?php echo anchor('#', 'Upload Song');?></p>
<article>
<div id="song_upload_info">
<?php echo $this->session->flashdata('info'); ?>
</div>
<form id="song_upload_form" method="post" enctype="multipart/form-data" action="profile/do_upload_song">
<input type="hidden" id="user_id" name="user_id" value="<?php echo $user->id_str;?>" />
<label for="title">Song Title</label>
<input type="text" name="title" id="title" size="30" value="<?php echo set_value('title'); ?>"/><br />
<label for="album"> Album Title </label>
<input type="text" name="album" id="album" size="30" value="<?php echo set_value('album'); ?>"/><br />
<label for="artist">Artist</label>
<input type="text" name="artist" id="artist" size="20" value="<?php echo set_value('artist'); ?>"/><br />
<input type="file" name="userfile" size="20" /><br />
<input type="radio" name="license" id="license" value="owner"/>I AM the artist/owner of this song and I have the right for distribution<br />
<input type="radio" name="license" id="license" value="not owner"/>I AM NOT the artist/owner of this song BUT I have the right for distribution</br>
<input type="checkbox" name="song_license_agreement"/>By selecting this option, I swear that all information entered is right<br />
<!-- <input type="submit" id="song_upload_submit" value="Upload Your Song"/>-->
<iframe id="upload_target" name="upload_target" src="" style="width:0;height:0;border:0px solid #fff;"></iframe>
</form>
</article>
<ul id="playlist">
</ul>
</section>
我的.js:
$(document).ready(function(){
refresh_song_list();
//upload song dialog
$('#music_features article').dialog({
autoOpen: false,
modal: true,
buttons:{
'upload': function(){
$('#song_upload_form').attr('target', $('#upload_target').attr('id'));
$('#song_upload_form').submit();
}
},
close: function(){
refresh_song_list();
}
});
$('#song_upload_menu').click(function(e){
$('#music_features article').dialog('open'); // this one won't work.. so strange...
e.preventDefault();
});
});
当有人点击#song_upload_menu
链接时,.js会打开对话框吗?但它不会。我已尝试将此代码执行到我的js控制台中:$('#music_features article').dialog('open');
并且它只返回此[]
这里的任何人都可以告诉我我的代码有什么问题吗?
更新:
我将这个命令发送到控制台:$('#music_features');
以找出一些东西。我发现music_features部分中没有这样的<article>
元素。
然后我从我的.js中删除了以下代码:
$('#music_features article').dialog({ ... });
之后我向控制台发出了相同的$('#music_features');
命令,它返回说我的DOM中有一个<article>
元素,它完全位于music_features中。 WHOAAAAAAA。怎么会这样?
答案 0 :(得分:2)
您无法选择商品标签。你可以在文章中添加唯一的id并使用它来调用jquery对话框吗?
$('#articleDialog').dialog({
...调用文章对话框'$('#articleDialog').dialog('open');
调用对话框<article id="articleDialog">
答案 1 :(得分:0)
您的DOM中没有ID为“music_features article”的元素。
您必须在dom中更新要在对话框中显示的元素的ID,或者在js代码中修复正确的ID。