简体   繁体   English

具有jQuery加载和返回值的Bootstrap 3.3模态

[英]Bootstrap 3.3 modal with jQuery load and return value

The latest version of Bootstrap modal options says that remote function is deprecated and will be removed in Bootstrap 4. So i'm trying to load a page with jQuery load. 最新版本的Bootstrap模态选项说,不赞成使用远程功能,并将在Bootstrap 4中将其删除。因此,我尝试使用jQuery加载来加载页面。 But how does this work? 但这如何工作? I can't find any example of this. 我找不到任何例子。

What I want is a modal that loads a page that I created as well. 我想要的是一个可以加载我也创建的页面的模式。 When you click a link in that page (the link is an url of an image), the href value must be returned to the textbox (ImageUrl) in the parent page. 当您单击该页面中的链接(链接是图像的URL)时,必须将href值返回到父页面中的文本框(ImageUrl)。

<div class="input-group">
    @Html.EditorFor(model => model.ImageUrl, new { htmlAttributes = new { @class = "form-control" } })
        <span class="input-group-btn">
            <button class="btn btn-default browsefiles" type="button" data-toggle="modal" data-target="#myModal"><i class="fa fa-search"></i></button>
        </span>
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Image</h4>
            </div>
            <div class="modal-body">
                External page must be loaded here
            </div>                            
        </div>
    </div>
</div>

I didn't knew that jQuery.load returned only html and that it will paste the html in the div that you have specified. 我不知道jQuery.load仅返回html,并且它将html粘贴到您指定的div中。 So when you want to "return" something, the destination is on the same page. 因此,当您要“返回”某些内容时,目标位置在同一页面上。 So you could set the return value directly in the page. 因此,您可以直接在页面中设置返回值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM