2014-12-08 56 views
2

我遇到了Mojolicious和隐藏问题,我想我可能只是不理解它的工作方式? 我有一个包含2个组合框的页面,当第一个条目更改时,我希望更新第二个条目中的选项。为什么我的数据没有被添加到存储在mojolicious?

因此,我添加了一个像下面这样的事件处理程序,然后调用我的控制器子例程'devicecommandset',然后将一个DBIx查询的结果放入我添加到我的存储区的散列数组中。

我然后只是渲染一些良性文本。我的子程序被调用,'@commandsets'中有预期的内容。但是,我无法在浏览器控制台中看到它(我正在以调试模式运行)。

我需要实际修改DOM来进行填充藏匿?基本上我只是试图从我的请求中获取数据来填充组合框选项。

在我的模板

$(document).ready(function() { 

$('select:not([name*="command"])').live('change', function (e) { 
    $.get('devicecommandset', { device: $(this).attr("value") }, 
      function (data) { 
       alert("Made it this far"); 
      }); 
     });   
}); 

在我的控制器

sub devicecommandset { 
    my $self = shift; 
    my $device = $self->param('device') || ''; 
    my @commandsets = $self->db->resultset('CommandSet')->search_commandsets_by_devicename($device); 
    $self->stash(commandsets => \@commandsets); 
    print Dumper(@commandsets); 
    $self->render(text => 'success'); 
} 

回答

2

你打印翻斗车到日志基本,而不是浏览器。您的存储不用于渲染,因为您没有引用它。使用内联渲染类型和“自卸车”助手。 Try:

$self->stash(commandsets => \@commandsets); 
$self->render(inline => '<%= dumper $commandsets %>'); 
相关问题