Skip to content

Commit

Permalink
Load the contents only when page is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
allenwq committed Feb 25, 2017
1 parent 66969e5 commit a6d1bc7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 54 deletions.
36 changes: 18 additions & 18 deletions client/app/bundles/course/assessment/assessments-edit.jsx
Expand Up @@ -4,27 +4,27 @@ import ProviderWrapper from 'lib/components/ProviderWrapper';
import storeCreator from './store';
import EditPage from './pages/EditPage';

const mountNode = document.getElementById('assessment-edit');
if (mountNode) {
const dataAttr = mountNode.getAttribute('data');
const data = JSON.parse(dataAttr);
const store = storeCreator({});
$(document).ready(() => {
const mountNode = document.getElementById('assessment-edit');
if (mountNode) {
const dataAttr = mountNode.getAttribute('data');
const data = JSON.parse(dataAttr);
const store = storeCreator({});

const Page = () => (
<ProviderWrapper store={store}>
<EditPage
modeSwitching={data.mode_switching}
folderAttributes={data.folder_attributes}
conditionAttributes={data.condition_attributes}
initialValues={{ ...data.attributes, password_protected: !!data.attributes.password }}
/>
</ProviderWrapper>
);
const Page = () => (
<ProviderWrapper store={store}>
<EditPage
modeSwitching={data.mode_switching}
folderAttributes={data.folder_attributes}
conditionAttributes={data.condition_attributes}
initialValues={{ ...data.attributes, password_protected: !!data.attributes.password }}
/>
</ProviderWrapper>
);

$(document).ready(() => {
render(
<Page />,
mountNode
);
});
}
}
});
34 changes: 17 additions & 17 deletions client/app/bundles/course/assessment/assessments-index.jsx
Expand Up @@ -4,26 +4,26 @@ import ProviderWrapper from 'lib/components/ProviderWrapper';
import storeCreator from './store';
import PopupDialog from './containers/PopupDialog';

const mountNode = $('.new-btn')[0];
if (mountNode) {
const data = mountNode.getAttribute('data');
const attributes = JSON.parse(data);
const store = storeCreator({ assessments: {} });
$(document).ready(() => {
const mountNode = $('.new-btn')[0];

const Page = () => (
<ProviderWrapper store={store}>
<PopupDialog
courseId={attributes.course_id}
categoryId={attributes.category_id}
tabId={attributes.tab_id}
/>
</ProviderWrapper>
);
if (mountNode) {
const data = mountNode.getAttribute('data');
const attributes = JSON.parse(data);
const store = storeCreator({ assessments: {} });
const Page = () => (
<ProviderWrapper store={store}>
<PopupDialog
courseId={attributes.course_id}
categoryId={attributes.category_id}
tabId={attributes.tab_id}
/>
</ProviderWrapper>
);

$(document).ready(() => {
render(
<Page />,
mountNode
);
});
}
}
});
26 changes: 13 additions & 13 deletions client/app/bundles/course/assessment/question/programming.jsx
Expand Up @@ -5,22 +5,22 @@ import ProviderWrapper from 'lib/components/ProviderWrapper';
import storeCreator from './programming/store';
import ProgrammingQuestion from './programming/ProgrammingQuestion';

const mountNode = document.getElementById('programming-question');
if (mountNode) {
const data = mountNode.getAttribute('data');
const props = Immutable.fromJS(JSON.parse(data));
const store = storeCreator(props);
$(document).ready(() => {
const mountNode = document.getElementById('programming-question');
if (mountNode) {
const data = mountNode.getAttribute('data');
const props = Immutable.fromJS(JSON.parse(data));
const store = storeCreator(props);

const Page = () => (
<ProviderWrapper {...{ store }}>
<ProgrammingQuestion />
</ProviderWrapper>
);
const Page = () => (
<ProviderWrapper {...{ store }}>
<ProgrammingQuestion />
</ProviderWrapper>
);

$(document).ready(() => {
render(
<Page />,
mountNode
);
});
}
}
});
12 changes: 6 additions & 6 deletions client/app/bundles/course/survey/surveys.jsx
Expand Up @@ -5,16 +5,16 @@ import ProviderWrapper from 'lib/components/ProviderWrapper';
import storeCreator from './store';
import routes from './routes';

const mountNode = document.getElementById('course-survey-component');
$(document).ready(() => {
const mountNode = document.getElementById('course-survey-component');

if (mountNode) {
const store = storeCreator({ surveys: {} });
if (mountNode) {
const store = storeCreator({ surveys: {} });

$(document).ready(() => {
render(
<ProviderWrapper {...{ store }}>
<Router routes={routes} history={browserHistory} />
</ProviderWrapper>
, mountNode);
});
}
}
});

0 comments on commit a6d1bc7

Please sign in to comment.