issue 749 fixed filebox ux error

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9989 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
devjin 2011-12-23 08:21:38 +00:00
parent d523bc8f7a
commit 6c7df0c23e
2 changed files with 12 additions and 8 deletions

View file

@ -85,7 +85,7 @@ function addRow(ulId){
var $ = jQuery;
var count = $('#'+ulId).children().length;
var clone = $('#'+ulId).find('li:last-child').prev().clone();
$('#'+ulId).find('li:last-child').prev().find('.__addBtn').remove();
$('#'+ulId).find('li:last-child').prev().find('.__addBtn').hide();
clone.find('input[name^="attribute_name"]').attr("name", "attribute_name"+count).attr('value', '')
.attr("id", "attribute_name"+count)
@ -93,15 +93,19 @@ function addRow(ulId){
clone.find('input[name^="attribute_value"]').attr("name", "attribute_value"+count).attr('value', '')
.attr("id", "attribute_value"+count)
.prev('label').attr('for', 'attribute_value'+count);
clone.find('.__deleteBtn').attr("href", "javascript:clearRow('fileUp', "+count+")");
$('#'+ulId).find('li:last-child').before(clone);
}
function clearRow(ulId,rowNumber){
function clearRow(target){
var $ = jQuery;
var count = $('#'+ulId).children().length - 1;
if (count <= 1) return;
var ulTag = $(target).closest('ul');
var count = ulTag.children().length - 1;
if (count <= 1){
ulTag.find('li:last-child').prev().find('.__addBtn').show();
return;
}
$('#'+ulId).find('input[name="attribute_name'+rowNumber+'"]').parent().remove();
$(target).closest('li').remove();
ulTag.find('li:last-child').prev().find('.__addBtn').show();
}

View file

@ -13,8 +13,8 @@
<li>
<label for="attribute_name1" style="display: inline;">{$lang->attribute_name} </label> <input type="text" class="notmulti" name="attribute_name1" id="attribute_name1" />
<label for="attribute_value1" style="display: inline; font-weight:bold">{$lang->attribute_value} </label> <input type="text" class="notmulti" name="attribute_value1" id="attribute_value1" />
<a class="__addBtn" href="javascript:addRow('fileUp')">{$lang->cmd_add}</a>
<a class="__deleteBtn" href="javascript:clearRow('fileUp',1)">{$lang->cmd_delete}</a>
<button type="button" class="text __addBtn" onclick="addRow('fileUp');">{$lang->cmd_add}</button>
<button type="button" class="text __deleteBtn" onclick="clearRow(this);">{$lang->cmd_delete}</button>
</li>
<li>
<label for="file" style="display: inline">{$lang->file}</label> <input type="file" name="addfile" id="file"/>