Ian
Ian

Reputation: 5883

Preserving jquery mobile styles when meteor js elements/fields update

I'm working on a Meteor project at the moment that utilises Meteor JS & jQuery Mobile. All is going well apart from certain circumstances where Meteor updates an element.

For example, JQM automagically adds a few surrounding divs to a select box for formatting purposes (.ui-select, .ui-btn, .ui-shadow, etc.) but when Meteor updates this element, whether from a remote or local db change, it reverts the element to a standard select box, in effect ruining the UI.

I was just wondering if there is a easy solution to this issue where Meteor calls on jQuery to make changes prior to updating the element?

Upvotes: 2

Views: 421

Answers (1)

Gajotres
Gajotres

Reputation: 57309

Dynamically added jQuery Mobile content must be enhanced.

It can be done in few ways, but most common ones are:

  1. In case you want to enhance only content

    $('#page-id').trigger('create');
    
  2. In case you want to enhance full page (content + header + footer)

    $('#page-id').trigger('pagecreate');
    

It is good to know that these method are performance extensive so you can always enhance widgets (buttons, listviews ...) separately. To find out more take a look at my other ARTICLE, to be transparent it is my personal blog, or find it HERE.

Upvotes: 2

Related Questions