Laravel刀片使用jQuery加载方法 [英] Laravel blade use jquery load method

查看:90
本文介绍了Laravel刀片使用jQuery加载方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用jquery呈现网页? Blade会不断重新加载整个页面,当您在网站上运行音乐时,这确实很烦人(它将不断停止). 通常我会使用Jquery的.load("HTMLPAGE")方法,但这似乎不起作用.

Is there any way to use jquery to render the webpage? Blade keeps reloading the whole page, which is really annoying when you have music running on the website (It will keep stopping). Normally i would use Jquery's .load("HTMLPAGE") method but this doesn't seem to work.

到目前为止,我做了什么: http://pastebin.com/0u1JeHD0

What i did so far: http://pastebin.com/0u1JeHD0

发生的事情是:第一个jquery做它的事&之后,laravel/blade重新加载整个视图.

What happens is: first jquery does its thing & after that laravel/blade reloads the whole view.

据我了解,您可以扩展视图以替换部分视图,但是当我尝试这样做时,它仍然会重新加载整个页面.

From what i understand is that you can extend views to replace parts of said views but when i try this it still reloads the whole page.

如果您有任何疑问,请问,因为我很难解释我的确切意思.

If you have any questions, please ask as i have a hard time explaining what i exactly mean.

PS:我不知道我需要这么说,但是:如果你在这里变得无礼,那就下车.我在问一个问题,据我所知,这是一个您可以执行此类操作的网站.

PS: I did not know i needed to say this but: if you are here to get rude, just get off. I'm asking a question and as far as I know this is a site where you can do such things.

推荐答案

这未经测试,但应该可以工作:

This was not tested, but should work:

在您的route.php文件上:

Route::get('/yoururl', function() {
    return View::make('view-to-load');
});

在您的app.js(或任何以javascript文件命名的)上:

$(document).ready(function() {
    $('#containner').load('/yoururl');
  });

通过这种方式,应将文件名为 view-to-load.blade.php 的刀片模板加载到ID为 containner 的HTML元素中.

This way your blade template with the file name view-to-load.blade.php should be loaded in the HTML elemente with the ID containner.

希望我有所帮助:)

注意:这可能不是最正确的方法,但重点很简单.

Note: This might not be the most correct way of doing this, but its simple enought, that was the point.

这篇关于Laravel刀片使用jQuery加载方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆