{"id":22300273,"url":"https://github.com/infinityloop-dev/lazy-component","last_synced_at":"2025-07-29T02:31:37.539Z","repository":{"id":56991130,"uuid":"234976898","full_name":"infinityloop-dev/lazy-component","owner":"infinityloop-dev","description":":wrench: Component for Nette framwork which helps with creation of lazy ajax loaded components.","archived":false,"fork":false,"pushed_at":"2020-03-28T18:30:35.000Z","size":29,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-21T18:42:48.147Z","etag":null,"topics":["component","lazy-loading","nette","nette-component","php"],"latest_commit_sha":null,"homepage":"https://www.infinityloop.dev","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infinityloop-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-19T22:22:31.000Z","updated_at":"2022-01-04T16:10:04.000Z","dependencies_parsed_at":"2022-08-21T10:10:41.093Z","dependency_job_id":null,"html_url":"https://github.com/infinityloop-dev/lazy-component","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinityloop-dev%2Flazy-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinityloop-dev%2Flazy-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinityloop-dev%2Flazy-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinityloop-dev%2Flazy-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infinityloop-dev","download_url":"https://codeload.github.com/infinityloop-dev/lazy-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227971952,"owners_count":17849421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","lazy-loading","nette","nette-component","php"],"created_at":"2024-12-03T18:10:14.513Z","updated_at":"2024-12-03T18:10:15.316Z","avatar_url":"https://github.com/infinityloop-dev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lazy component\n\n:wrench: Component for Nette framwork which helps with creation of lazy ajax loaded components.\n\n## Introduction\n\nComponent which renders empty in the beggining and is populated by signal request.\n\n## Installation\n\nInstall package using composer\n\n```\ncomposer require infinityloop-dev/lazy-component\n```\n\n## Dependencies\n\n- PHP \u003e= 7.4\n- [nette/application](https://github.com/nette/application)\n- [nette/utils](https://github.com/nette/utils)\n\n## How to use\n\n- Create new component and extend `\\Infinityloop\\LazyComponent\\LazyComponent` instead of `\\Nette\\Application\\UI\\Control`.\n- Trigger `handleLoadComponent` to load and redraw component.\n- Use macro `{control componentName}` to render your component as you would normally.\n- Additionaly use `{control componentName:loadComponentLink}` to get URL for `loadComponent` signal.\n    - Useful for rendering URL (eg. into data attributes) so you can easily trigger signal from javascript.\n- Make sure `LazyCompoennt::render()` method is called if you choose to override it.\n    - Preferably use `beforeRender()` to pass variables into template. \n    - `beforeRender()` method is not called when empty template is used (when component is not loaded).\n- Template for your component is automaticaly deduced to be have same name (and path) as your `.php` file.\n    - File extension is simply swapped to `.latte`.\n- By default the FontAwesome 5 spinner is used as placeholder. Override `EMPTY_TEMPLATE` constant to use different empty template file.\n\n### Example lazy tab content\n\nTab header:\n```\n\u003cli class\"tab\" data-load-component=\"{control myComponent:loadComponentLink}\"\u003eTab name\u003c/li\u003e\n```\nTab content:\n```\n\u003cdiv class=\"tab-content\"\u003e\n    {control myComponent}\n\u003c/div\u003e\n```\nJQuery ajax request on click:\n```\n$(\".tab[data-load-component]\").one('click',function (event) {\n    const link = $(this).data(\"load-component\");\n    $.nette.ajax({\n        method: 'GET',\n        url: link,\n    });\n});\n```\n\n- Load event is executed only once ([jqery.one](https://api.jquery.com/one/)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinityloop-dev%2Flazy-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfinityloop-dev%2Flazy-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinityloop-dev%2Flazy-component/lists"}