Magento使用jQuery填充管理面板中的表单字段

Pan*_*nos 0 forms jquery magento magento-1.7

我是magento的新手,我现在正在创建一个eshop.我想添加一些jquery代码来预填充我想要的一些字段.例如,我想在添加新的产品类别时自动选择"isAnchor"= true和active = true.此外,我想在添加新产品时自动选择某个税收选择并使用我想要的某些值预填充其他一些字段作为默认值.

有人可以建议我应该在每个案例中放置代码以实现我的目标吗?

提前致谢.

Nid*_*esh 5

步骤1 >>下载jquery并将其保存到js/jquery目录

第3步>>创建一个新的js文件js/custom/autoPopulate.js并添加以下内容.

jQuery(document).ready(function(){
   alert('succeed!!'); 
});
Run Code Online (Sandbox Code Playgroud)

第2步>>创建app/design/adminhtml/default/default/layout/local.xml

第3步>>将以下代码添加到上面创建的文件中

<layout>
    <adminhtml_catalog_product_edit>
        <reference name="head">
            <action method="addItem">
                <type>js</type>
            <!-- Jquery file path here-->
                <name>jquery/JQUERY_FILE_NAME.js</name>
            </action>
            <action method="addItem">
                <type>js</type>
                <name>custom/autoPopulate.js</name>
            </action>
        </reference>
    </adminhtml_catalog_product_edit>
</layout>
Run Code Online (Sandbox Code Playgroud)

完成上述步骤后,转到目录>>产品>>编辑部分,看到它提醒"成功!!".如果是,请在auoPopulate.js中编写代码.小心,magento使用ajax加载一些数据,最好在执行代码之前等待完成ajax请求,否则可能会抛出错误