Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jquery Mobile Bundle Laravel Package

bmatzner/jquery-mobile-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation: Run composer require bmatzner/jquery-mobile-bundle:^1.4 and update dependencies. Register the bundle in AppKernel.php under $bundles.

  2. Asset Setup: Execute php app/console assets:install web (or --symlink for development). Verify assets appear in web/bundles/bmatznerjquerymobile/.

  3. First Use Case: Include jQuery Mobile in a Twig template:

    {# app/Resources/views/base.html.twig #}
    <link rel="stylesheet" href="{{ asset('bundles/bmatznerjquerymobile/css/jquery.mobile.min.css') }}">
    <script src="{{ asset('bundles/bmatznerjquery/js/jquery.min.js') }}"></script>
    <script src="{{ asset('bundles/bmatznerjquerymobile/js/jquery.mobile.min.js') }}"></script>
    

    Add a basic jQuery Mobile page structure:

    <div data-role="page" id="home">
        <div data-role="header">Header</div>
        <div data-role="content">Content</div>
    </div>
    

Implementation Patterns

Core Workflows

  1. Theming: Override the default theme by extending the CSS bundle:

    <link rel="stylesheet" href="{{ asset('bundles/bmatznerjquerymobile/css/themes/default/jquery.mobile.theme.min.css') }}">
    

    Customize via SASS (compile locally) or inline styles.

  2. Dynamic Page Loading: Use jQuery Mobile’s AJAX navigation:

    // app/Resources/public/js/app.js
    $(document).on('pagebeforechange', function(e, data) {
        if (data.toPage.attr('data-role') === 'page') {
            // Preload or modify content
        }
    });
    
  3. Symfony Integration:

    • Routing: Use Symfony’s router to generate URLs for AJAX-loaded pages:
      <a href="{{ path('app_home') }}" data-role="button">Home</a>
      
    • Controllers: Return Twig templates for mobile pages:
      // src/AppBundle/Controller/MobileController.php
      public function homeAction(Request $request) {
          return $this->render('mobile/home.html.twig');
      }
      
  4. Asset Management:

    • Development: Use --symlink to avoid asset duplication.
    • Production: Minify assets via Webpack Encore or Symfony’s assets:install --no-debug.

Advanced Patterns

  • Hybrid Apps: Combine with CapacitorJS or Cordova by including the bundle’s JS in a wrapper script.
  • Progressive Enhancement: Load jQuery Mobile only on mobile devices via Twig:
    {% if app.request.headers.get('User-Agent') matches '/Mobile|Android|iPhone/i' %}
        {# Include jQuery Mobile assets #}
    {% endif %}
    

Gotchas and Tips

Pitfalls

  1. Asset Paths:

    • Issue: Hardcoded paths in templates break after assets:install.
    • Fix: Always use {{ asset() }} with the correct bundle path (e.g., bundles/bmatznerjquerymobile/).
  2. jQuery Conflicts:

    • Issue: jQuery Mobile requires jQuery 1.x (this bundle includes v1.11.0). Conflicts arise if other bundles load jQuery 3+.
    • Fix: Explicitly load the bundle’s jQuery first:
      <script src="{{ asset('bundles/bmatznerjquery/js/jquery.min.js') }}"></script>
      
  3. Deprecated Features:

    • Issue: jQuery Mobile 1.4.x lacks support for modern features (e.g., data-transition="none" is limited).
    • Workaround: Use custom CSS/JS for transitions or upgrade to a maintained fork (e.g., jQuery Mobile 1.5).
  4. Symfony 4+ Compatibility:

    • Issue: The bundle targets Symfony 2.x and may not work with Flex/auto-wiring.
    • Fix: Manually register the bundle in config/bundles.php:
      return [
          // ...
          Bmatzner\JQueryMobileBundle\BmatznerJQueryMobileBundle::class => ['all' => true],
      ];
      

Debugging Tips

  • Console Errors: Check for Uncaught ReferenceError (missing jQuery) or jQuery is not defined (incorrect load order).
  • Network Tab: Verify assets load at /bundles/bmatznerjquerymobile/.... Use --symlink in dev to avoid cache issues.
  • Mobile Testing: Use Chrome DevTools’ Device Mode or real devices to test touch interactions.

Extension Points

  1. Custom Themes: Override the default theme by copying bundles/bmatznerjquerymobile/css/themes/default/ to your project and modifying it.

  2. JavaScript Extensions: Add custom scripts after jQuery Mobile’s initialization:

    <script src="{{ asset('bundles/bmatznerjquerymobile/js/jquery.mobile.min.js') }}"></script>
    <script src="{{ asset('js/custom-mobile.js') }}"></script>
    
  3. Asset Versioning: Append a query string to bust caches in development:

    <script src="{{ asset('bundles/bmatznerjquerymobile/js/jquery.mobile.min.js?v='~app.version) }}"></script>
    

Performance Quirks

  • Bundle Size: The minified bundle (~100KB) may impact mobile performance. Consider lazy-loading or tree-shaking.
  • CSS Specificity: jQuery Mobile’s styles use !important. Override with higher specificity or !important in your CSS.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle