Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用JS模糊将焦点转移到div_Javascript_Jquery_Modal Dialog_Blur - Fatal编程技术网

Javascript 使用JS模糊将焦点转移到div

Javascript 使用JS模糊将焦点转移到div,javascript,jquery,modal-dialog,blur,Javascript,Jquery,Modal Dialog,Blur,很抱歉,我刚刚开始使用JS函数,但是我们的页面上有一个搜索框,当调用时,我认为它使用ajax将搜索数据填充到div中。我们以前使用jquery live search 在搜索查询中,我们有许多链接,它们都有一个类,这个类与jquery模式相关。旧版本使用模糊功能工作。我正在尝试将功能移植到新的搜索 我们曾经拥有的 jquery搜索: <form method="post" action="<? echo constructurl($platform_name,"ht

很抱歉,我刚刚开始使用JS函数,但是我们的页面上有一个搜索框,当调用时,我认为它使用ajax将搜索数据填充到div中。我们以前使用jquery live search

在搜索查询中,我们有许多链接,它们都有一个类,这个类与jquery模式相关。旧版本使用模糊功能工作。我正在尝试将功能移植到新的搜索

我们曾经拥有的

jquery搜索:

         <form method="post" action="<? echo constructurl($platform_name,"https") ?>/process/feedbackcreateuser" enctype="multipart/form-data" class="form-right">


    <input name="q" type="text" placeholder="Enter your idea or feedback ... " name="title..." style="width:100%; " value="<? echo $captchamessage ?>">
    <div id="jquery-live-search" style="display:none;"></div>

    <script src="<? echo $asset_url ?>/3rdparty/feedback/jquery.liveSearch.js"></script>
    <script>
    jQuery('input[name="q"]').liveSearch({url: '<? echo constructurl($platform_name,"https")?>/process/searchfeedbackuser/?c=<? echo $id ?>&q='});
    </script>       

</form>
让它工作的JS:

<script type="text/javascript"> <!-- this allows search results to have same js functions -->
$(document).ready(function() { 
$("input[name='q']").blur(function() { 
$("div#jquery-live-search [rel='clickover']").clickover({ html : true} ); 
$("div#jquery-live-search input, div#jquery-live-search textarea").placeholder();
$("div#jquery-live-search .dialog-iframe-card").dialog2IFrame(  { 
            height:900,
              closeOnOverlayClick: true, 
              closeOnEscape: true, 
              removeOnClose: true, 
              showCloseHandle: true,
}); 
$("div#jquery-live-search .dialog-iframe-report").dialog2IFrame(    { 
            height:900,
              closeOnOverlayClick: false, 
              closeOnEscape: true, 
              removeOnClose: true, 
              showCloseHandle: true,
}); 
}); 
}); 
</script>
我们现在所拥有的

JS搜索不再是jQuery了

<script type="text/javascript">
    $(document).ready(function() {
        $('#form form').submit(function(){
            $('#content').load('<? echo constructurl($platform_name,"https")?>/process/searchfeedback/?c=<? echo $id ?>', { 'q': $('input[name="query"]').val()}).slideDown('500')                  
            return false;
        });
    });
    $(function(){
    $('form').each(function () {
        var thisform = $(this);
        thisform.prepend(thisform.find('button.default').clone().css({
            position: 'absolute',
            left: '-999px',
            top: '-999px',
            height: 0,
            width: 0


        }));
    });
});
    </script>

<div id="form">
<form class="form">


<div class="input-group" style="margin-bottom:10px">
<input type="text" name="query" placeholder="Enter your idea or feedback ... "   class="feedback-search  validate[required] form-control search-main" >
  <span class="input-group-btn">
<input type="submit" name="submit" value="Go!" class="btn btn-search">
</span>
</div>

</div></form>
 <form method="post" action="<? echo constructurl($platform_name,"https") ?>/process/feedbackcreate" enctype="multipart/form-data" class="form"  class="form-right">
</form>
<div id="content">
</div> 
我一直在尝试类似的事情,但运气不好

<script type="text/javascript"> <!-- this allows search results to have same js functions -->
$(document).ready(function() { 
$("#form").blur(function() { 
$("div#content [rel='clickover']").clickover({ html : true} ); 
$("div#content input, div#jquery-live-search textarea").placeholder();
$("div#content .dialog-iframe-card").dialog2IFrame( { 
            height:900,
              closeOnOverlayClick: true, 
              closeOnEscape: true, 
              removeOnClose: true, 
              showCloseHandle: true,
}); 
$("div#content .dialog-iframe-report").dialog2IFrame(   { 
            height:900,
              closeOnOverlayClick: false, 
              closeOnEscape: true, 
              removeOnClose: true, 
              showCloseHandle: true,
}); 
}); 
}); 
</script>
您的HTML存在以下问题:

在开始一个新标签之前,您似乎根本没有关闭标签。所以您有嵌套的表单,而这是不可能发生的,所以您应该首先修复它,因为$'form'.eachfunction{很可能不会为您做任何事情。不完全确定您为什么要在表单中预先添加一个宽度为0、高度为0且在页面上没有位置的克隆按钮。这样做似乎有点尴尬。为什么不首先使用相同的按钮?为什么要克隆它

此外,您还没有在此行末尾添加分号:

$'content'.load'/process/searchfeedback/?c=',{'q':$'input[name=query]'.val}.slideDown'500'

这将导致语法错误

您应该在浏览器中打开javascript错误报告,以便能够查看所有jQuery/javascript错误,并逐一更正这些错误。完成此操作后,它甚至可能会自行修复

另外,请确保加载jQuery,因为您仍然在编码中使用它……这里有一个好的CDN供jQuery使用:


我想不出这个问题,所以我只是将正在工作的JS调用弹出到动态内容的页面中,它成功了!

谢谢,我关闭了表单标记,但仍然存在相同的问题。有一个JS错误,但它来自jquery-Uncaught SyntaxError:意外标识符jquery.JS:7078匿名函数jquery.JS:7078 b.extend.globalEval jquery.JS:7082 b.fn.extend.domManip jquery.js:9597 b.fn.extend.append jquery.js:9597匿名函数jquery.js:9597 b.extend.access jquery.js:7246 b.fn.extend.html jquery.js:9597匿名函数jquery.js:9597 c jquery.js:7341 p.fireWith jquery.js:7403 k jquery.js:9597 Rhanks-我已经做了更新,但不确定在模糊函数中放什么。我尝试的一切似乎都失败了。此外,.clickover不是jQuery的一个功能,尽管我相信它在jQuery引导中,所以假设您需要确保jQuery引导px已加载。而且您应该确保您正在加载jQuery,因为您仍在使用它。