GVKun编程网logo

javascript-动态更新Extjs autoEl:’button’文本和CSS(js动态更新数据)

10

关于javascript-动态更新ExtjsautoEl:’button’文本和CSS和js动态更新数据的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于asp.net–Javascript

关于javascript-动态更新Extjs autoEl:’button’文本和CSSjs动态更新数据的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于asp.net – Javascript之前asp:ButtonField点击、Autocomplete Textbox Example javascript实现自动完成成功_javascript技巧、button没写type=button会导致点击时提交_javascript技巧、CSS Button调用javascript函数等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

javascript-动态更新Extjs autoEl:’button’文本和CSS(js动态更新数据)

javascript-动态更新Extjs autoEl:’button’文本和CSS(js动态更新数据)

我是ExtJS的新手,想动态更改按钮的文本:
我的要求是预览按钮.为了提供预览,我创建了如下组件:

{
  xtype: ''container'',
  width: ''100%'',
  padding: ''20 0 20 0'',
  itemId: ''preview-container'',
  items: [
       {
          xtype: ''component'',
          itemId: ''preview'',
          autoEl    :''button''
       }
  ]
}

我的更新预览方法如下,我想从此函数更新按钮的文本:
    我已经尝试过如下,但无法正常工作..

updatePreview: function () {
    var previewEl = this.down(''#preview'').getEl(),
        formValues = this.getForm().getValues(),
        newStyles = {};
    if (previewEl) {
        previewEl.text = formValues.name;
        previewEl.applyStyles(newStyles);
    }
}

更新:包括我所有的代码示例

    Ext.widget({
        xtype   : ''mz-form-widget'',
        itemId: ''specialButtonRuleForm'',
        defaults: {
            xtype: ''textfield'',
            editable: false,
            listeners: {
                change: function (cmp) {
                    // alert(1);
                   cmp.up(''#specialButtonRuleForm'').updatePreview();
                }
            }
        },
        items: [
            {
                xtype: ''textfield'',
                name: ''name'',
                fieldLabel: ''Button label'',
                allowBlank: false
            },
            {
                xtype: ''container'',
                width: ''100%'',
                padding: ''20 0 20 0'',
                itemId: ''preview-container'',
                    items: [
                        {
                            xtype: ''component'',
                            itemId: ''preview'',
                            autoEl    :''button''
                        }
                    ]
            }
        ],

        listeners: {
            afterrender: function (cmp) {
                // alert(2);
                cmp.updatePreview();
            }
        },

        updatePreview: function () {
            // alert(3);
            var previewEl = this.down(''[itemId=preview]''),
                formValues = this.getForm().getValues(),
                newStyles = {};

            if (previewEl) {
                previewEl.setText(formValues.name);
                previewEl.applyStyles(newStyles);
            }
        }

    });

解决方法:

因为使用的是组件,所以没有通常的按钮方法.

您将需要做PreviewEl.getEl().dom.value =’New Text’;

总结

以上是小编为你收集整理的javascript-动态更新Extjs autoEl:’button’文本和CSS全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

原文地址:https://codeday.me/bug/20191028/1955750.html

asp.net – Javascript之前asp:ButtonField点击

asp.net – Javascript之前asp:ButtonField点击

我在Asp.net应用程序中有一个GridView控件,它具有< asp:buttonField> type =“image”和CommandName =“Delete”。

在到达OnRowDelete事件之前有没有办法执行一段JavaScript?

删除行之前,我只需要一个简单的确认。

谢谢!

编辑:请注意< asp:ButtonField>标签没有OnClientClick属性。

解决方法

我将使用一个TemplateField,并使用常规的asp:Button或者asp:ImageButton填充ItemTemplate,这取决于需要什么。然后可以执行RowCommand事件在截取Delete命令时要执行的逻辑。

在这些按钮之一中,我将使用OnClientClick属性在此之前执行JavaScript确认对话框。

<script type="text/javascript">
   function confirmDelete()
   {
       return confirm("Are you sure you want to delete this?");
   }
</script>

...

<asp:TemplateField>
  <ItemTemplate>
     <asp:ImageButton ID="DeleteButton" runat="server"
        ImageUrl="..." AlternateText="Delete" ToolTip="Delete"
        CommandName="Delete" CommandArgument='<%# Eval("ID") %>'
        OnClientClick="return confirmDelete();" />
  </ItemTemplate>
</asp:TemplateField>

Autocomplete Textbox Example javascript实现自动完成成功_javascript技巧

Autocomplete Textbox Example javascript实现自动完成成功_javascript技巧

复制代码 代码如下:

<script> <BR>var isOpera = navigator.userAgent.indexOf("Opera") > -1; <BR>var isIE = navigator.userAgent.indexOf("MSIE") > 1 && !isOpera; <BR>var isMoz = navigator.userAgent.indexOf("Mozilla/5.") == 0 && !isOpera; <BR>function textboxSelect (oTextbox, iStart, iEnd) { <BR> switch(arguments.length) { <BR> case 1: <BR> oTextbox.select(); <BR> break; <BR> case 2: <BR> iEnd = oTextbox.value.length; <BR> /* falls through */ <br><br> case 3: <BR> if (isIE) { <BR> var oRange = oTextbox.createTextRange(); <BR> oRange.moveStart("character", iStart); <BR> oRange.moveEnd("character", -oTextbox.value.length + iEnd); <BR> oRange.select(); <BR> } else if (isMoz){ <BR> oTextbox.setSelectionRange(iStart, iEnd); <BR> } <BR> } <BR> oTextbox.focus(); <BR>} <BR>/* <BR>function textboxReplaceSelect (oTextbox, sText) { <BR> if (isIE) { <BR> var oRange = oTextbox.createTextRange(); <BR> oRange.text = sText; <BR> oRange.collapse(true); <BR> oRange.select(); <BR> } else if (isMoz) { <BR> var iStart = oTextbox.selectionStart; <BR> oTextbox.value = oTextbox.value.substring(0, iStart) + sText + oTextbox.value.substring(oTextbox.selectionEnd, oTextbox.value.length); <BR> oTextbox.setSelectionRange(iStart + sText.length, iStart + sText.length); <BR> } <BR> oTextbox.focus(); <BR>} <BR>*/ <BR>function autocompleteMatch (sText, arrValues) { <BR> for (var i=0; i < arrValues.length; i++) { <BR> if (arrValues[i].indexOf(sText) == 0) { <BR> return arrValues[i]; <BR> } <BR> } <BR> return null; <BR>} <BR>function autocomplete(oTextbox, oEvent, arrValues) { <BR> switch (oEvent.keyCode) { <BR> case 38: //up arrow <BR> case 40: //down arrow <BR> case 37: //left arrow <BR> case 39: //right arrow <BR> case 33: //page up <BR> case 34: //page down <BR> case 36: //home <BR> case 35: //end <BR> case 13: //enter <BR> case 9: //tab <BR> case 27: //esc <BR> case 16: //shift <BR> case 17: //ctrl <BR> case 18: //alt <BR> case 20: //caps lock <BR> case 8: //backspace <BR> case 46: //delete <BR> return true; <BR> break; <BR> default: <BR> // 下面这一行用处不大(被注释) <BR> //textboxReplaceSelect(oTextbox, isIE ? oTextbox.value/*oEvent.keyCode*/ : oEvent.charCode); <BR> var iLen = oTextbox.value.length; <BR> var sMatch = autocompleteMatch(oTextbox.value, arrValues); <BR> if (sMatch != null) { <BR> oTextbox.value = sMatch; <BR> textboxSelect(oTextbox, iLen, oTextbox.value.length); <BR> } <br><br> return false; <BR> } <BR>} <BR> </script>
<script> <BR> var arrValues = ["red", "orange", "yellow", "green", "blue", "indigo", "violet", "brown"]; <BR> </script>

Autocomplete Textbox Example


Type in a color in lowercase:输入一个以小写字母开头的颜色(英文单词,比如:r、 b等)


button没写type=button会导致点击时提交_javascript技巧

button没写type=button会导致点击时提交_javascript技巧

有个地方很奇怪:点击了一个弹窗中的按钮,没想到弹窗消失了,经公司的js高手调试,发现了其中的奥秘

复制代码 代码如下:

添加调查问卷

加一个type ="button" 就好了:
复制代码 代码如下:

添加调查问卷

不同的浏览器支持的规则不同

CSS Button调用javascript函数

CSS Button调用javascript函数

我创建了一个CSS按钮,如下所示:

<div>Click me!</div>

现在我不知道如何在点击这个按钮时执行javascript函数?! onClick喜欢HTML按钮在这里不起作用.

你能帮我么?谢谢!

编辑:这是我基本上:

HTML

<spanonClick="farmArbeiter()">Kaufe Arbeiter</span>

onClick和onclick都不起作用.
javascript

function farmArbeiter() { alert("it works");}

解决方法

使用javascript将click事件处理程序附加到它:

document.getElementById("BT1").addEventListener("click",function(){
    alert("oh snap,i was clicked...");
});
<divid="BT1">Click me!</div>

今天关于javascript-动态更新Extjs autoEl:’button’文本和CSSjs动态更新数据的介绍到此结束,谢谢您的阅读,有关asp.net – Javascript之前asp:ButtonField点击、Autocomplete Textbox Example javascript实现自动完成成功_javascript技巧、button没写type=button会导致点击时提交_javascript技巧、CSS Button调用javascript函数等更多相关知识的信息可以在本站进行查询。

本文标签:

上一篇javascript-iPad / iPhone的自定义CSS /元标记

下一篇javascript – EXT JS 5 – 覆盖ViewController定义?(js覆盖方法)