Created
August 2, 2013 08:15
-
-
Save darkleaf/6138275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ -> | |
$groups_selector = $('#user_advertisement_company_fb_page_id') | |
$fb_accounts_selector = $('#user_advertisement_company_facebook_account_id') | |
$stub_message = $('<option/>', text: 'Идет загрузка…') | |
group_filler = -> | |
if @value | |
previous_value = $('option', $groups_selector).val() | |
$groups_selector.html $stub_message | |
$.getJSON "/api/facebook_accounts/#{@value}/pages", (data) -> | |
$groups_selector.empty() | |
$.each data, (index, page) -> | |
$groups_selector.append $('<option/>', value: page.id, text: page.name) | |
$groups_selector.val previous_value | |
else | |
$groups_selector.empty() | |
group_filler.call $fb_accounts_selector[0] | |
$fb_accounts_selector.change group_filler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment