<%= f.label t("fb_app_plugin.views.myprofile.catalogs.profile_chooser_label") %>
<%= f.text_field :profile_ids, "data-limit" => "1", "data-placeholder" => t('fb_app_plugin.views.page_tab.profile.placeholder'), onchange: 'fb_app.page_tab.config.profile.onchange($(this))' %>

<%= javascript_tag do %>
  jQuery(document).ready(function() {
    var selector = '#page-tab-<%= page_tab.id || 'new' %> .config-type-profile #page_tab_profile_ids'

    fb_app.page_tab.config.profile.onchange($(selector))

    open_graph.autocomplete.init(
      <%= url_for(controller: :fb_app_plugin_page_tab, action: :enterprise_search).to_json %>,
      selector,
      <%= [page_tab.profile].compact.map{ |p| {value: p.id, label: render('open_graph_plugin_myprofile/ac_profile', profile: p), } }.to_json %>,
      {tokenfield: {limit: 1}}
    )
    
    jQuery(selector)
      .on('tokenfield:createdtoken', function (e) {
        jQuery(selector+'-tokenfield').toggle();
      })
      .on('tokenfield:removedtoken', function (e) {
        jQuery(selector+'-tokenfield').toggle();
      })
    console.log(selector)
    console.log(jQuery(selector))
  })
<% end %>

<%= f.label t("fb_app_plugin.views.myprofile.catalogs.profile_chooser_label") %>
<%= f.text_field :profile_ids, "data-limit" => "1", "data-placeholder" => t('fb_app_plugin.views.page_tab.profile.placeholder'), onchange: 'fb_app.page_tab.config.profile.onchange($(this))' %>

<%= javascript_tag do %>
  jQuery(document).ready(function() {
    var selector = '#page-tab-<%= page_tab.id || 'new' %> .config-type-profile #page_tab_profile_ids'

    fb_app.page_tab.config.profile.onchange($(selector))

    open_graph.autocomplete.init(
      <%= url_for(controller: :fb_app_plugin_page_tab, action: :enterprise_search).to_json %>,
      selector,
      <%= [page_tab.profile].compact.map{ |p| {value: p.id, label: render('open_graph_plugin_myprofile/ac_profile', profile: p), } }.to_json %>,
      {tokenfield: {limit: 1}}
    )
    
    jQuery(selector)
      .on('tokenfield:createdtoken', function (e) {
        jQuery(selector+'-tokenfield').hide();
      })
      .on('tokenfield:removedtoken', function (e) {
        jQuery(selector+'-tokenfield').show();
      })
    console.log(selector)
    console.log(jQuery(selector))
  })
<% end %>

Make the toggle really toggle
Make the toggle really toggle