doudiaozhi6658 2013-02-20 16:59
浏览 48

使用EXTJS警报消息框调用PHP脚本

I am currently trying to call the PHP script upon clicking OK button on EXTJS message alert box.

For some reason it doesn't even display the Alert box when I use handler. However when I used Listener it displays the Alert box but doesn't call the php script upon clicking OK button. I read on different blogs and come to know Handler is the best way to go forward

I will appreciate if somebody can help me or point me to the right direction. I am using the latest release of EXTJS4

Below is the EXTJS tree panel code I've written using handler;

var treePanel = Ext.create('Ext.tree.Panel', {
    id: 'tree-panel',
    title: 'Available Database',
    region: 'north',
    split: true,
    height: 360,
    minSize: 150,
    rootVisible: false,
    autoScroll: true,
    store: store,

    handler: function() {
        if (treePanel.getSelectionModel().hasSelection()) {
            var selValue = treePanel.getSelectionModel().getSelection();

            Ext.MessageBox.alert('Press OK to confirm your subscription <br>' + selValue[0].data.text,
                function(btn, text) {
                    if (btn == 'ok') {
                        Ext.Ajax.request({
                            url: 'addSubscription.php',
                            params: {
                                nodetext: text,
                                parentid: selectedNode[0].data.id
                            },
                            success: function(response) {
                                var id = response.responseText;
                                grid.getView().refresh();
                            }
                        })
                    } else {
                        Ext.MessageBox.alert('Record already subscribed');
                    }
                });
        }
    }

});
  • 写回答

1条回答 默认 最新

  • dtvnnhh8992 2013-02-20 19:02
    关注

    Ext.tree.Panel have not 'handler' property in config. Handler is a function that is executed when you click on some of the components - such as buttons. You can add button on your treePanel toolbar, and use button handler:

    ...
    tbar: [{
        xtype: 'button',
        text: 'Subscribe',
        handler: function(button) {
            ...
        }
    }],
    ...
    

    See on jsfiddle: http://jsfiddle.net/FFvLa/

    but doesn't call the php script upon clicking OK button.

    The function must be passed as the third argument in Ext.Msg.alert:

    http://jsfiddle.net/FFvLa/2/

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?